Skip to content

Instantly share code, notes, and snippets.

@alexolinux
Last active May 21, 2024 10:06
Show Gist options
  • Save alexolinux/7baa59f25c81b2506604bdefdc53e2a3 to your computer and use it in GitHub Desktop.
Save alexolinux/7baa59f25c81b2506604bdefdc53e2a3 to your computer and use it in GitHub Desktop.
Removing a Namespace stuck in terminating state.

k82-namespace-stuck-terminating


  1. Defining Namespace Variable (namespace name)
NS="my-namespace"
  1. Retrieve the namespace api state specification
kubectl get namespace $NS -o json > ns.json
  1. Go back to the previous terminal >> Edit ns.json >> Remove the content inside of spec.finalizers:
"spec": {
        "finalizers": [
            "kubernetes" <- ("""Remove this value and save the file""")
        ]
    }
  1. Open a new tab on terminal, and run Kube Proxy
kube proxy
  1. Return to the previous tab, so execute:
curl -k -H "Content-Type: application/json" -X PUT --data-binary @ns.json "http://127.0.0.1:8001/api/v1/namespaces/${NS}/finalize"
  1. Check if your namespace was removed:
kubectl get namespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment