Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm delete all releases

I'm trying find a way to delete all deployed releases in Helm.

It appears that Helm does not support deleting all releases, with --all or otherwise.

Would there be another way to delete all Helm releases in one command?

like image 385
grizzthedj Avatar asked Dec 14 '17 16:12

grizzthedj


People also ask

How do I delete pods with Helm?

To remove the pods, list the pods with kubectl get pods and then delete the pods by name. To delete the Helm release, find the Helm release name with helm list and delete it with helm delete . You may also need to clean up leftover StatefulSets , since helm delete can leave them behind.

How does Helm uninstall work?

Synopsis. This command takes a release name and uninstalls the release. It removes all of the resources associated with the last release of the chart as well as the release history, freeing it up for future use. Use the '--dry-run' flag to see which releases will be uninstalled without actually uninstalling them.

Does Helm uninstall remove PVC?

When Helm installs a chart including a statefulset which uses volumeClaimTemplates to generate new PVCs for each replica created, Helm loses control on those PVCs.


4 Answers

To delete all Helm releases in Linux(in Helm v2.X) with a single command, you can use some good old bash. Just pipe the output of helm ls --short to xargs, and run helm delete for each release returned.

helm ls --all --short | xargs -L1 helm delete

Adding --purge will delete the charts as well, as per @Yeasin Ar Rahman's comment.

helm ls --all --short | xargs -L1 helm delete --purge

On Windows, you can delete all releases with this command, again, with --purge deleting the charts as well.

helm del $(helm ls --all --short) --purge

Update: As per @lucidyan comment, the --purge arg is not available in Helm v3.

like image 178
grizzthedj Avatar answered Oct 28 '22 17:10

grizzthedj


For helm 3 you have to provide namespaces so there is an awk step before xargs :

helm ls -a --all-namespaces | awk 'NR > 1 { print "-n "$2, $1}' | xargs -L1 helm delete

This results in commands like:

helm delete -n my-namespace my-release

like image 38
jhnclvr Avatar answered Oct 28 '22 15:10

jhnclvr


This worked for me in a powershell cmd window:

helm del $(helm ls --all --short) --purge
like image 17
Rod Avatar answered Oct 28 '22 16:10

Rod


helm delete $(helm ls --short)

Description:

helm ls --short gives a list of releases ids.

helm delete id1 id2 id3 deletes releases with ids: id1, id2, id3.

So combining them we get: helm delete $(helm ls --short)

like image 15
imos Avatar answered Oct 28 '22 16:10

imos