Delete namespace and also delete helm deployment?

8/5/2019

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?

-- red888
google-kubernetes-engine
kubectl
kubernetes
kubernetes-helm

2 Answers

8/6/2019

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.

-- Amit Kumar Gupta
Source: StackOverflow

8/6/2019

There is a PR created to cleanup all resources deployed from helm. follow the link --> https://github.com/helm/helm/issues/1464

hopefully in the future release it will be addressed

-- P Ekambaram
Source: StackOverflow