Skip to content

Instantly share code, notes, and snippets.

@sax1johno
Last active August 30, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sax1johno/103b86fa09a21983b49f19c65a7be6ab to your computer and use it in GitHub Desktop.
Save sax1johno/103b86fa09a21983b49f19c65a7be6ab to your computer and use it in GitHub Desktop.
Fix for Kubernetes Namespace being stuck in the "Terminating" state
# Sometimes, when you attempt to delete a namespace in kubernetes, it can get stuck in the "terminating" state.
# This generally happens when there are resources still assigned to that namespace when it is deleted.
# The finalizers are unable to confirm that all resources are cleared out, so they fail and stay locked in the "terminating" state.
# You can fix it by doing the following:
# First, proxy the kubernetes api cluster to your local system
$ kubectl serve
# find each namespace impacted
$ kubect get namespace <ns> -o json > temp.json
# vi temp.json and remove the finalizer entry for "openshift.io/origin"
# for example
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "testing",
"selfLink": "/api/v1/namespaces/testing",
"uid": "33074e57-cb72-11e5-9d3d-28d2444e470d",
"resourceVersion": "234",
"creationTimestamp": "2016-02-04T19:05:04Z",
"deletionTimestamp": "2016-02-04T19:05:54Z"
},
"spec": {
"finalizers": [
"openshift.io/org" <--- remove me
]
},
"status": {
"phase": "Terminating"
}
}
$ curl -H "Content-Type: application/json" -X PUT --data-binary @temp.json http://127.0.0.1:8080/api/v1/namespaces/<name_of_namespace>/finalize
# wait a moment, and you should see your namespace removed
$ kubectl get namespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment