Created
January 21, 2023 03:43
-
-
Save bohrasd/4769035b7aa670cf7382aee837ec9223 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# Remove terminating namespaces | |
# Usage: ./remove-terminating-ns.sh | |
TERMINATING_NS=$(kubectl get ns | grep Terminating | awk '{print $1}') | |
kubectl proxy & | |
PROXY_PID=$! | |
for ns in $TERMINATING_NS; do | |
echo "Removing namespace $ns" | |
kubectl get ns $ns -o json > $ns.json | |
sed -i -e 's/"kubernetes"//g' $ns.json | |
curl -k -H "Content-Type: application/json" -X PUT --data-binary @$ns.json http://localhost:8001/api/v1/namespaces/$ns/finalize | |
kubectl delete ns $ns | |
rm $ns.json | |
done | |
kill $PROXY_PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment