Skip to content

Instantly share code, notes, and snippets.

@samcre
Created October 28, 2019 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcre/03dac6e87f28e0f31e5fe65dea541baa to your computer and use it in GitHub Desktop.
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
#!/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