I have an app which I'm deploying with Helm. Once deployed, the app itself sometimes creates other Kubernetes resources (like
Services) in the same namespace as the app. When I run
helm delete on the Helm release, it deletes all the resources originally created by Helm, but it leaves the resources that were created by the app. I would like to clean up these resources as well and I'm wondering if I can make Helm do so automatically.
I've tried applying the recommended labels from here such as
app.kubernetes.io/instance to my new resources, but Helm still doesn't delete them.
I also looked in the Helm manual but I can't find any clarity about how Helm decides what resources it "owns" and can delete.
(I know that I can use a Helm
post-delete hook for this, but it feels cleaner to get Helm's normal deletion process to do this.)
So I am not 100% sure about your setup, however, If you are talking about CRD's and controllers, Kubernetes uses a concept called finalizers and ownerRefs, finalizers are akin to before deleteing a resource do X (https://book.kubebuilder.io/reference/using-finalizers.html very good reference),
OwnerReferences essentially means that when I delete a resource anything that has that resource set as its owner will be deleted, I have set it in a custom controller but never tried manually setting it on the yaml (https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#owners-and-dependents)