How To Delete Helm Deployment And Namespace

March 11, 2021

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.

How to Delete Helm Deployment and Namespace

Prerequisites

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 <<em>namespace_name</em>>

List all Helm deployments in all namespaces by running:

helm list --all-namespaces
Terminal output of listing all namespaces with the command 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 <<em>namespace_name</em>>

Alternatively, use the alias:

helm delete <deployment name> --namespace <<em>namespace_name</em>>

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
Terminal output of helm uninstall

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:

Terminal output of the command kubectl get namespace

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
Terminal output of kubectl delete namespace

The namespace no longer appears on the list and is available for use again.

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.

Was this article helpful?
YesNo
Milica Dancuk
Milica Dancuk is an aspiring technical writer at phoenixNAP and a data nerd. Her background in Electrical Engineering and Computing and her teaching experience give her a unique set of skills - being able to easily explain complex technical concepts through her content.
Next you should read
How to Fix "helm has no deployed releases" Error
March 4, 2021

When upgrading from a failed deployment, Helm will produce a "helm has no deployed releases" error...
Read more
How to Use Environment Variables with Helm Charts
February 24, 2021

Helm charts are used to collect and package Kubernetes resources into simple and efficient clusters...
Read more
Get Helm Values For a Helm Release
February 10, 2021

Helm releases get updated and so do the values. Each change of Helm values is tracked. Learn how to get Helm...
Read more
How to Add, Update or Remove Helm Repositories
December 21, 2020

Helm is Kubernetes' equivalent to apt and yum. It is a package manager used for deploying applications, which...
Read more
  • © 2021 Copyright phoenixNAP | Global IT Services. All Rights Reserved.