62

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?

Taylor D. Edmiston
  • 12,088
  • 6
  • 56
  • 76
grizzthedj
  • 7,131
  • 16
  • 42
  • 62

8 Answers8

96

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.

grizzthedj
  • 7,131
  • 16
  • 42
  • 62
29

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

jhnclvr
  • 9,137
  • 5
  • 50
  • 55
16

This worked for me in a powershell cmd window:

helm del $(helm ls --all --short) --purge
Rod
  • 386
  • 3
  • 7
  • 2
    `helm del $(helm ls --short --deleted) --purge` to purge all DELTED chart. – fkpwolf Aug 01 '18 at 09:44
  • For Windows PS this is indeed the correct answer, the accepted answer does not work on Windows. – Ahab Apr 16 '19 at 13:21
  • `helm del $(helm ls --all --short |grep test) --purge` to delete and purge only deletes release starting with test name. – Vikas Apr 23 '20 at 15:58
15

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)

Quer
  • 405
  • 7
  • 16
iimos
  • 4,767
  • 2
  • 33
  • 35
  • 4
    While this code may answer the question, providing additional context regarding **how** and **why** it solves the problem would improve the answer's long-term value. – Alexander Jun 14 '18 at 13:24
3

I regularly delete all releases in Helm too, so I thought it'd be useful to make a Helm plugin for it.

Install:

helm plugin install https://github.com/tedmiston/helm-delete-all-plugin --version 0.0.3

(You may be able to omit the --version x part on newer versions of Helm.)

Usage:

helm delete-all

https://github.com/tedmiston/helm-delete-all-plugin

Taylor D. Edmiston
  • 12,088
  • 6
  • 56
  • 76
2

If you use xargs in the alpine container then you will get the following error;

xargs: unrecognized option: L

So, you can use the following command to delete all releases in a specific namespace for the helm v3.

helm uninstall -n <namespace> $(helm ls --short -n <namespace>)

hbceylan
  • 968
  • 10
  • 10
0

There is a really good plugin for delete all helm releases from all namespaces (The previous plugin in this post doesn't work for me) . Install:

helm plugin install https://github.com/BarelElbaz/helm-delete-all

usage:

helm delete-all

you can provide more flags such as --deletePersistent for delete PVCs or skipping a specific namespace by --except-namespace

Barel elbaz
  • 426
  • 3
  • 8
0

To delete all releases in a particular namespace

helm ls  --short  -n <<namespace>> | xargs -L1 helm uninstall  -n <<namespace>>
Başar Söker
  • 606
  • 8
  • 16