Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jakoberpf/7f4e21be24de56f4c39abc77c9f1480b to your computer and use it in GitHub Desktop.
Save jakoberpf/7f4e21be24de56f4c39abc77c9f1480b to your computer and use it in GitHub Desktop.
This script will terminate a given namespace, even if its stuck in the terminating state. Note that this will not trigger any ressource cleanup.
echo ATTENTION: THIS IS UNSAFE!
echo Which namespace would you like me to terminate\?
read NAMESPACE_TO_DESTROY
echo I will terminate namespace $NAMESPACE_TO_DESTROY\!
(
kubectl proxy &
kubectl get namespace $NAMESPACE_TO_DESTROY -o json |jq '.spec = {"finalizers":[]}' >temp.json
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE_TO_DESTROY/finalize
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment