How to force delete a namespace?
A namespace has finalizers
in spec
(not in metadata
):
spec:
finalizers:
- kubernetes
To force delete a namespace:
# Start the proxy in the background
$ kubectl proxy &
# Dump the namespace and remove `finalizers`
$ kubectl get namespace NAMESPACE -o json | jq '.spec = {"finalizers":[]}' > temp.json
# Force delete the namespace
$ curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/NAMESPACE/finalize