How To Force-Complete A Kubernetes Finalizer

Sometimes deleting a namespace gets stuck due to finalizers breaking

Corey Regan's avatar

Published on July 11, 2024

1 min read


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.

bash:Proxy requests to kubectl
kubectl proxy

In another shell window, send the payload to the finalizer

bash:Generic example, replace $namespace with your namespace/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
bash:This example finalizes the olm namespace, change olm to your namespace/finalizer
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