kubewarden-controller
kubewarden-controller copied to clipboard
Increase the usage of `metadata.ownerReferences`
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
finalizerfrom the Policy Server instance
@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.
I've rebased the PR for this issue on top of #730 . Moving this to block until we merge that PR.
As now we merge all the refactoring PRs in the controller, I'll resume this work. Starting by retesting the upgrade process