kubewarden-controller icon indicating copy to clipboard operation
kubewarden-controller copied to clipboard

Increase the usage of `metadata.ownerReferences`

Open flavio opened this issue 1 year ago • 1 comments

Each PolicyServer resource owns a series of Kubernetes resources:

  • Deployment
  • Secret: to hold the certificates
  • ConfigMap
  • Service

Currently none of these resources are set to be owned by the PolicyServer instance that created them. Because of that, we have this custom code that deals with the cleanup of these resources.

We can rely on Kubernetes' garbage collector to cleanup all these resources, removing code from our code base.

Acceptance criteria

  • [ ] Ownership relationships are set accordingly between a Policy Server and its sub-resources
  • [ ] The Policy Server reconciliation loop is no longer in charge of cleaning up all the sub-resources. The controller only takes care of triggering the deletion of all the policies scheduled on the Policy Server instance and then, once no policy is scheduled, removes the finalizer from the Policy Server instance

flavio avatar Feb 29 '24 17:02 flavio

@kubewarden/kubewarden-developers this is block due an issue in the upgrade process of the controller. As we discussed during one of our daily, I'll work on code to use the createOrUpdate helper function from the controller-runtime package to simplify our code and workaround this.

jvanz avatar Apr 18 '24 11:04 jvanz

I've rebased the PR for this issue on top of #730 . Moving this to block until we merge that PR.

jvanz avatar Apr 26 '24 17:04 jvanz

As now we merge all the refactoring PRs in the controller, I'll resume this work. Starting by retesting the upgrade process

jvanz avatar May 07 '24 12:05 jvanz