Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Garbage collection of cluster-wide resources owned by operator deployment fails #524

Open
anekdoti opened this issue Feb 8, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@anekdoti
Copy link

anekdoti commented Feb 8, 2023

Describe the bug

The installation of webhooks in the init container of the operator creates a service as well as a ValidatingWebhookConfiguration and a MutatingWebhookConfiguration. All three resources are created with an owner reference to the deployment of the operator. However, the latter two resources are cluster-wide, and thus can not be owned by a namespaced resource the deployment (see https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/#owner-references-in-object-specifications).
Hence, the resources are not cleaned up on removal of the operator deployment but instead generate warning events as described in the link above.

To reproduce

  1. Deploy a KubeOps operator on your Kubernetes cluster
  2. Remove the operator deployment

Expected behavior

The ValidatingWebhookConfiguration and the MutatingWebhookConfiguration are cleaned up as well.

Screenshots

The warning event created for each of the two mentioned resources:

  Type     Reason                    Age    From                          Message
  ----     ------                    ----   ----                          -------
  Warning  OwnerRefInvalidNamespace  3m42s  garbage-collector-controller  ownerRef [apps/v1/Deployment, namespace: , name: my-operator, uid: 46c64771-eedf-41ca-b65c-d28b6f9326d7] does not exist in namespace ""

Additional Context

Kubernetes: v1.23
KubeOps: 7.0.6

@anekdoti anekdoti added the bug Something isn't working label Feb 8, 2023
@anekdoti
Copy link
Author

A possible fix might be to not set the owner references to the Deployment, but e.g. to the ClusterRoleBinding.

@buehler
Copy link
Owner

buehler commented Feb 23, 2023

This absolutely makes sense :-D did not know that was the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants