Introduction
If unwanted or multiple copies of Helm deployments exist, there is a way to delete them and free up space. On the other hand, deleting a Kubernetes cluster namespace removes the components along with the namespace.
This article explains how to delete a Helm deployment and namespace.
Prerequisites
- A Kubernetes cluster installed and configured
- Helm installed and configured
- Access to a CLI or terminal
Delete Helm Deployment
Deleting a Helm deployment removes the components without deleting the namespace.
Important note: Multiple Helm releases with the same name can coexist on different namespaces. Make sure to find the exact deployment and namespace before deleting it.
1. List Helm Deployments
List Helm deployments in the current namespace with:
helm list
To list deployments in a specific namespace, use:
helm list --namespace <namespace_name>
List all Helm deployments in all namespaces by running:
helm list --all-namespaces
The example above shows deployments of the same name existing on different namespaces. Find the exact release and the namespace, and proceed to the next step.
2. Delete Helm Deployment
To remove an installed Helm deployment, run:
helm uninstall <deployment name> --namespace <namespace_name>
Alternatively, use the alias:
helm delete <deployment name> --namespace <namespace_name>
The terminal outputs a confirmation of removal. For example, the command below removes a deployment named phoenix-chart on the namespace other:
helm uninstall phoenix-chart --namespace other
In Helm 2, use the --purge
option to delete the release and related Kubernetes components:
helm delete <deployment name> --purge
List Helm deployments with helm list
to confirm the release is no longer there.
Note: Did you know that you can rollback changes in Helm? Follow the link to found out how.
Delete Helm Deployment and Namespace
Deleting the namespace also deletes all the residing components. However, removing all deployments within a namespace does not remove the namespace.
Although there is an option to generate a namespace when deploying a chart with --create-namespace
, there is no method to remove it when deleting a release using Helm commands. Delete the namespace using the kubectl command.
1. List All Namespaces
List all namespaces with:
kubectl get namespace
The output prints all the namespaces, their status, and age:
2. Delete Namespace
To delete a namespace and all the components, run:
kubectl delete <namespace name>
The terminal prints a confirmation message. For example, to remove the other namespace:
kubectl delete namespace other
The namespace no longer appears on the list and is available for use again.
Note: You should also check out our step-by-step guide on how to delete a Kubernetes namespace.
Conclusion
Removing a Helm deployment or namespace requires careful consideration. Make sure to check which component you are deleting before removing anything.
Next, consider learning how to use Helm environment variables for Helm charts. Using Helm environment variables helps define the Kubernetes environment.