Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@agolomoodysaada
Created November 4, 2019 11:04
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 agolomoodysaada/d9ef9e33224bf8799c5c4697464842a0 to your computer and use it in GitHub Desktop.
Save agolomoodysaada/d9ef9e33224bf8799c5c4697464842a0 to your computer and use it in GitHub Desktop.
How to delete stuck kubernetes namespaces
# run kubectl proxy on a separate terminal
kubectl get ns | grep Terminating | awk '{print $1}' | while read NS
do
echo $NS
kubectl get ns --export -o json $NS | grep -v '"kubernetes"' > /tmp/$NS.json
curl -H "Content-Type: application/json" -X PUT --data-binary @/tmp/$NS.json http://127.0.0.1:8001/api/v1/namespaces/$NS/finalize
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment