Skip to content

Instantly share code, notes, and snippets.

@mayooot
Forked from chrisedrego/force-namespace-destroy.sh
Created December 25, 2024 10:38
Show Gist options
  • Save mayooot/78b9ceabaebb7f43e88c7f818d27652a to your computer and use it in GitHub Desktop.
Save mayooot/78b9ceabaebb7f43e88c7f818d27652a to your computer and use it in GitHub Desktop.
force delete namespace
kubectl proxy &
echo "Entering the namespace details: "
read ns
cat<<EOF >./ns.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"labels": {
"name": "$ns"
},
"name": "$ns"
},
"spec": {
"finalizers": [
]
}
}
EOF
kubectl delete ns/$ns &
curl -k -H "Content-Type: application/json" -X PUT --data-binary @ns.json http://127.0.0.1:8001/api/v1/namespaces/$ns/finalize
kilall kubectl
@mayooot
Copy link
Author

mayooot commented Dec 25, 2024

LGTM

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