Can I make Helm automatically delete resources created by my Helm-created app?


I have an app which I'm deploying with Helm. Once deployed, the app itself sometimes creates other Kubernetes resources (like Deployments and 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 and 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 pre-delete or post-delete hook for this, but it feels cleaner to get Helm's normal deletion process to do this.)

-- tom

1 Answer


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 ( 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 (

-- Spazzy757
Source: StackOverflow