summaryrefslogtreecommitdiffstats
path: root/kubernetes/helm/plugins/undeploy/undeploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'kubernetes/helm/plugins/undeploy/undeploy.sh')
-rwxr-xr-xkubernetes/helm/plugins/undeploy/undeploy.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/kubernetes/helm/plugins/undeploy/undeploy.sh b/kubernetes/helm/plugins/undeploy/undeploy.sh
new file mode 100755
index 0000000000..02b5d34c65
--- /dev/null
+++ b/kubernetes/helm/plugins/undeploy/undeploy.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+usage() {
+cat << EOF
+Delete an umbrella Helm Chart, and its subcharts, that was previously deployed using 'Helm deploy'.
+
+Example of deleting all Releases that have the prefix 'demo'.
+ $ helm undeploy demo
+
+ $ helm undeploy demo --purge
+
+Usage:
+ helm undeploy [RELEASE] [flags]
+
+Flags:
+ --purge remove the releases from the store and make its name free for later use
+EOF
+}
+
+undeploy() {
+ RELEASE=$1
+ FLAGS=$2
+
+ array=($(helm ls -q | grep $RELEASE))
+ n=${#array[*]}
+ for (( i = n-1; i >= 0; i-- ))
+ do
+ helm del "${array[i]}" $FLAGS
+ done
+}
+
+if [[ $# < 1 ]]; then
+ echo "Error: command 'undeploy' requires a release name"
+ exit 0
+fi
+
+case "${1:-"help"}" in
+ "help")
+ usage
+ ;;
+ "--help")
+ usage
+ ;;
+ "-h")
+ usage
+ ;;
+ *)
+ undeploy $1 ${@:2}
+ ;;
+esac
+
+exit 0 \ No newline at end of file