How To Force-Complete A Kubernetes Finalizer
Sometimes deleting a namespace gets stuck due to finalizers breaking
Sometimes you need to nuke a namespace, but doing so deletes resources a finalizer depends on, leaving the delete operation getting stuck.
You can trick the finalizer into receiving a "completed
" event by proxying a PUT request to kubectl.
kubectl proxy
In another shell window, send the payload to the finalizer
curl -k -H "Content-Type: application/json" -X PUT --data-binary '{"kind":"Namespace","apiVersion":"v1","metadata":{"name":"$namespace"},"spec":{"finalizers":[]}}' http://127.0.0.1:8001/api/v1/namespaces/$namespace/finalize
curl -k -H "Content-Type: application/json" -X PUT --data-binary '{"kind":"Namespace","apiVersion":"v1","metadata":{"name":"olm"},"spec":{"finalizers":[]}}' http://127.0.0.1:8001/api/v1/namespaces/olm/finalize