Repository navigation
Closed
Labels
language/helmIssue is related to a Helm operator projecttriage/needs-informationIndicates an issue needs more information in order to work on it.
Milestone
Description
Type of question
For Helm Operator install, why is the ownerReferences set properly for deployments and services but not for clusterrole and clusterrolebinding? Is this the expected behavior? If I wish to, how do I add the ownerReferences to those resources?
Question
What did you do?
I created a helm operator which deploys clusterrole and clusterrolebinding.
$ operator-sdk new nginx-ingress-operator \
--api-version=example.com/v1alpha1 \
--kind=NginxIngress \
--type=helm \
--helm-chart stable/nginx-ingress
$ cd nginx-ingress-operator/
$ kubectl apply -f deploy/crds/example.com_nginxingresses_crd.yaml
$ kubectl apply -f deploy/crds/example.com_v1alpha1_nginxingress_cr.yaml
$ operator-sdk run --local
What did you expect to see?
When I looked at the clusterrole, it doesn't have the ownerReferences
$ kubectl get clusterrole/example-nginxingress-nginx-ingress -o yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: "2020-03-26T19:48:02Z"
labels:
app: nginx-ingress
chart: nginx-ingress-1.29.5
heritage: Helm
release: example-nginxingress
name: example-nginxingress-nginx-ingress
resourceVersion: "529"
selfLink: /apis/rbac.authorization.k8s.io/v1/clusterroles/example-nginxingress-nginx-ingress
uid: f0e53286-59d0-4eff-92c3-49af9325eeb7
rules:
- apiGroups:
- ""
What did you see instead? Under which circumstances?
When I looked at deployment, I see the ownerReferences
$ kubectl get deployments/example-nginxingress-nginx-ingress-controller -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
...
ownerReferences:
- apiVersion: example.com/v1alpha1
blockOwnerDeletion: true
controller: true
kind: NginxIngress
name: example-nginxingress
uid: 6f4fd985-9f61-43db-a5b6-75de20bfec11
resourceVersion: "708"
selfLink: /apis/apps/v1/namespaces/default/deployments/example-nginxingress-nginx-ingress-controller
uid: 053e56ba-0b95-4dac-bf66-1c615c5199ef
Environment
- operator-sdk version:
$ operator-sdk version
operator-sdk version: "v0.16.0-dirty", commit: "55f1446c5f472e7d8e308dcdf36d0d7fc44fc4fd", go version: "go1.13.8 linux/amd64"
- Kubernetes version information:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:20:10Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.4", GitCommit:"224be7bdce5a9dd0c2fd0d46b83865648e2fe0ba", GitTreeState:"clean", BuildDate:"2020-01-14T01:25:43Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
- Kubernetes cluster kind:
KIND
$ kind version
kind v0.7.0 go1.13.6 linux/amd64
Additional context
Many thanks.
Metadata
Metadata
Assignees
Labels
language/helmIssue is related to a Helm operator projecttriage/needs-informationIndicates an issue needs more information in order to work on it.
Activity
joelanford commentedon Mar 26, 2020
Kubernetes does not allow namespace-scoped resources to own cluster-scoped resources, so the helm operator has a check that prevents adding those invalid owner references.
Is the lack of owner references on those cluster-scoped resources causing a problem?
mikeshng commentedon Mar 26, 2020
Thanks Joe for the quick reply.
In some cases, removing the finalizer then deleting the helm operator resource might leave behind some orphans like clusterrole because it doesn't have the ownerReferences so it doesn't get garbage collected.
I guess this is the expected behavior. Manually removing the finalizer means some manual cleanup operations should be done afterwards.
Thanks again, please feel free to close the issue if there is nothing that needs to be done here.
joelanford commentedon Mar 26, 2020
That's correct. From a cleanup perspective, the finalizer will ensure that all release resources are removed. Manually removing the finalizer effectively means that
helm uninstallwon't happen, and you are then relying on garbage collection.Right now, I'm pretty sure the release secret ALSO does not have an owner reference, so that would be orphaned as well.
One other thing I'm curious about though: the helm-operator sets up watches for the resources that are created in a release. So for example, if the nginx-ingress deployment is manually edited, the operator will detect the change and reconcile it so that it is re-aligned with the release manifest.
Thinking about this, I'm now questioning if the same reconciliation works for release resources that are cluster scoped. Would you mind verifying what happens when you manually edit both a namespace-scoped and cluster-scoped resource that has been deployed by the operator? My hunch is that the namespace-scoped resource will be reset but the cluster-scoped resource won't.
mikeshng commentedon Mar 31, 2020
The namespace-scoped resource did reset.
When I edit the deployment and change the port to
8080it reverted back to80In
The cluster-scoped resource did not reset as you predicted.
When I edit the clusterrole,
Added a
getand it persisted.mikeshng commentedon Mar 31, 2020
https://github.com/operator-framework/operator-sdk/blob/v0.16.0/pkg/helm/controller/controller.go#L146
It seems like not watching the cluster scope resources are intentional.
joelanford commentedon Apr 20, 2020
It is, but since we already have a finalizer that runs
helm uninstallI think we should theoretically be able to remove that constraint and setup watches on the cluster-scoped resources without relying on owner references.For example, we may be able to use the
EnqueueRequestForAnnotationhandler in these cases.bharathi-tenneti commentedon Apr 20, 2020
/assign
bharathi-tenneti commentedon Apr 27, 2020
@mikeshng
Trying to reproduce the issue, to confirm you used
kubectl editto manually edit the resources(deployment, and ClusterRole) ?mikeshng commentedon Apr 27, 2020
It was a while ago, but I am sure it was either
kubectl editoroc edit