- Issue, can’t delete a namespace/project and is stuck in a “Terminating” status
oc delete project fishbone
oc get projects fishbone
NAME DISPLAY NAME STATUS
fishbone Fishbone Terminating
Solution
- Define the namespace/project to delete
export NAMESPACE=fishbone
- Cleanup the finalizers section from the namespace definition and define a json file with that
oc get namespace $NAMESPACE -o=json | jq '.spec = {"finalizers":[]}' > $NAMESPACE.json { "apiVersion": "v1", "kind": "Namespace", "metadata": { "annotations": "openshift.io/description": "", "openshift.io/display-name": "Fishbone", "openshift.io/requester": "system:admin", "openshift.io/sa.scc.mcs": "s0:c24,c14", "openshift.io/sa.scc.supplemental-groups": "1000580000/10000", "openshift.io/sa.scc.uid-range": "1000580000/10000" }, "creationTimestamp": "2021-02-20T03:29:59Z", "deletionTimestamp": "2021-02-20T03:31:35Z", "name": "fishbone", "resourceVersion": "270664", "selfLink": "/api/v1/namespaces/fishbone", "uid": "885c4440-6f05-4e72-a103-28e61705406f" }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "conditions": [ . . . ], "phase": "Terminating" }
- Apply the json file from the previous step to delete the finalizers and therefore the deletion of the namespace/project
curl -k -H "authorization: Bearer $(oc whoami --show-token)" -H "Content-Type: application/json" -X PUT --data-binary @$NAMESPACE.json $(oc whoami --show-server)/api/v1/namespaces/$NAMESPACE/finalize
- Verify that the namspace/project has been deleted
oc get projects $NAMESPACE Error from server (NotFound): namespaces "fishbone" not found
References: