Skip to content

Instantly share code, notes, and snippets.

@snobu
Last active May 10, 2021 11:33
Show Gist options
  • Save snobu/4c3f344025f4e8af927f10994ffc2597 to your computer and use it in GitHub Desktop.
Save snobu/4c3f344025f4e8af927f10994ffc2597 to your computer and use it in GitHub Desktop.
cleanup-k8s-terminating-namespace.sh
#!/bin/bash
# Usage ./cleanup-k8s-terminating-namespace.sh <namespace>
NAMESPACE=$1
echo Cleaning up namespace $1
kubectl proxy &
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' > /tmp/temp.json
curl -i -k -H "Content-Type: application/json" -X PUT \
--data-binary @/tmp/temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize
rm /tmp/temp.json
pkill kubectl
@snobu
Copy link
Author

snobu commented Jan 10, 2020

Easier -

$ kubectl edit namespace <namespace>

Remove all finalizers. Save.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment