Kubernetes: Remove stuck namespace in Terminating state
Reading time: 1 min
Original Source: https://bobcares.com/blog/remove-kubernetes-namespace-stuck-in-terminating/
To fix that you have to get the schema of the namespace as json File:
kubectl get ns <NAMESPACE_NAME> -o json > namespace.json
\
This command created a namespace.json file in your current directory.
Edit it with your favorite Text editor and search for this occurency:
"spec": { "finalizers": [ "kubernetes" ] },\
Now just remove the “kubernetes” line from the file.
Now it looks like this:
"spec": { "finalizers": [ ] },\
Save the file and exit your editor.
Now execute this command:
kubectl replace --raw "/api/v1/namespaces/<NAMESPACE_NAME>/finalize" -f namespace.json
\
Now your namespace got terminated and you are ready to move forward.
Have a nice day :)
`