Delete namespace and also delete helm deployment?

10,855

Deleting a namespace deletes all the resources in it- except the helm deployment

This can't be (deleting a namespace implies deleting everything in it, there aren't any exceptions), and must means that the state representing Helm's concept of a deployment doesn't live in that namespace. Helm stores these as config maps in the TILLER_NAMESPACE. See here and here.

It's not surprising that if you create some resources with helm and then go "under the hood" and delete those resources directly via kubectl, Helm's state of the world won't result in that deployment disappearing.

Deleting a helm deployment deletes all resource in it- except the namespace

That sounds like expected behaviour. Presumably you created the namespace out of band with kubectl, it's not part of your Helm deployment. So deleting the Helm deployment wouldn't delete that namespace.

If you kubectl create namespace NS and helm install CHART --namespace NS then it's not surprising that to clean up, you need to helm delete the release and then kubectl delete the namespace.

The only way I could imagine to do that would be for the Helm chart itself to both create a namespace and create all subsequent namespace-scoped resources within that namespace. Here is an example that appears to do such a thing.

Share:
10,855
red888
Author by

red888

Updated on June 05, 2022

Comments

  • red888
    red888 almost 2 years

    I deploy my helm deploys to isolated namespaces

    Deleting a namespace deletes all the resources in it- except the helm deployment

    Deleting a helm deployment deletes all resource in it- except the namespace

    I have to do this which seems redundant:

    helm del `helm ls NAMESPACE --short` --purge
    kubectl delete namespace NAMESPACE
    

    Id rather just delete my namespace and have the helm deploy also purged- is this possible?