Remove kubernetes namespace stuck in Terminating

Quick Post:

tmc agent was stuck 🙁

Cause: This is because of a stuck resource in kubernetes.

Solution: One way to get around this is to remove the finalizer spec to allow kubernetes in to clean-up the namespace.


  • Dump the namespace spec in json format
kubectl get ns <namespace to remove> -o json > namespace.json
  • Edit the namespace.json and remove the finalizer portion in the spec. it should look like below



remove everything inside the spec portion.
  • Manually patch the namespace using the following command
kubectl replace --raw "/api/v1/namespaces/<NAMESPACE NAME>/finalize" -f namespace.json

… and that’s it. Hope that helps 🙂

  1. a Reply

    And get orphaned objects belonging to that namespace?

Leave a Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.