Last active
April 20, 2022 00:02
-
-
Save unguiculus/d915e911ba04f1f97ecea4f617a2eef5 to your computer and use it in GitHub Desktop.
Kubernetes
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 | |
set -e | |
set -o pipefail | |
kubectl proxy & | |
proxy_pid="$!" | |
trap 'kill "$proxy_pid"' EXIT | |
for ns in $(kubectl get namespace --field-selector=status.phase=Terminating --output=jsonpath="{.items[*].metadata.name}"); do | |
echo "Removing finalizers from namespace '$ns'..." | |
curl -H "Content-Type: application/json" -X PUT "127.0.0.1:8001/api/v1/namespaces/$ns/finalize" -d @- \ | |
< <(kubectl get namespace "$ns" --output=json | jq '.spec = { "finalizers": [] }') | |
echo | |
echo "Force-deleting namespace '$ns'..." | |
kubectl delete namespace "$ns" --force --grace-period=0 --ignore-not-found=true | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment