Created
October 28, 2019 14:50
-
-
Save samcre/03dac6e87f28e0f31e5fe65dea541baa to your computer and use it in GitHub Desktop.
Get all namespaces with tiller deployment, and remove al Pull Request deployed with Helm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#shellcheck disable=SC2116 | |
TILLER_NS=$( kubectl get pods --all-namespaces --selector name=tiller --output custom-columns=:.metadata.namespace | grep -v ^$ ) | |
export TILLER_NS | |
for ns in $( echo "$TILLER_NS" ) | |
do | |
helm ls --tiller-namespace "$ns" \ | |
| cut -f1 \ | |
| grep -E ".*-[0-9]*$" \ | |
| xargs -I RELEASE helm delete --purge RELEASE --tiller-namespace "$ns" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment