Created
August 9, 2022 11:50
-
-
Save nitinsatish/8f79d8ba58c4daeb8211ed85318f0459 to your computer and use it in GitHub Desktop.
[Delete terminating namespace] #k8s
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 | |
function delete_namespace () { | |
echo "Deleting namespace $1" | |
kubectl get namespace $1 -o json > tmp.json | |
sed -i 's/"kubernetes"//g' tmp.json | |
kubectl replace --raw "/api/v1/namespaces/$1/finalize" -f ./tmp.json | |
rm ./tmp.json | |
} | |
TERMINATING_NS=$(kubectl get ns | awk '$2=="Terminating" {print $1}') | |
for ns in $TERMINATING_NS | |
do | |
delete_namespace $ns | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment