Openshift Namespace Terminating Problem

0
941

I encountered this problem,when I try to remove namespace.It hasnt got any resource but Its state is still terminating so I cant delete this namespace.After my research, I found the problem answer.

Firstly, you should get your namespace output in jsonfile with below command.

oc get namespaces openshift-metrics-o json > openshift-metrics.json
{
  "kind": "Namespace",
  "apiVersion": "v1",
  "metadata": {
    "name": "openshift-metrics",
    "selfLink": "/api/v1/namespaces/openshift-metrics/finalize",
    "uid": "04684928-d03b-11e8-af42-005056b02f5d",
    "resourceVersion": "87438930",
    "creationTimestamp": "2018-10-15T05:27:33Z",
    "deletionTimestamp": "2019-04-03T08:00:34Z",
    "annotations": {
      "openshift.io/description": "Prometheus",
      "openshift.io/display-name": "",
      "openshift.io/node-selector": "role=infra",
      "openshift.io/sa.scc.mcs": "s0:c18,c17",
      "openshift.io/sa.scc.supplemental-groups": "1000340000/10000",
      "openshift.io/sa.scc.uid-range": "1000340000/10000"
    }
  },
  "spec": {
    "finalizers": [
      "kubernetes"
    ]
  },
  "status": {
    "phase": "Terminating"
  }

Then edit the json file and remove the “kubernetes” part.Finally looks like below;

    "finalizers": [
    ]
  },

Now we try to making manual API call with json file.

kubectl proxy &
curl -k -H "Content-Type: application/json" -X PUT --data-binary @openshift-metrics.json http://127.0.0.1:8001/api/v1/namespaces/openshift-metrics/finalize
{
  "kind": "Namespace",
  "apiVersion": "v1",
  "metadata": {
    "name": "openshift-metrics",
    "selfLink": "/api/v1/namespaces/openshift-metrics/finalize",
    "uid": "04684928-d03b-11e8-af42-005056b02f5d",
    "resourceVersion": "87481574",
    "creationTimestamp": "2018-10-15T05:27:33Z",
    "deletionTimestamp": "2019-04-03T08:00:34Z",
    "annotations": {
      "openshift.io/description": "Prometheus",
      "openshift.io/display-name": "",
      "openshift.io/node-selector": "role=infra",
      "openshift.io/sa.scc.mcs": "s0:c18,c17",
      "openshift.io/sa.scc.supplemental-groups": "1000340000/10000",
      "openshift.io/sa.scc.uid-range": "1000340000/10000"
    }
  },
  "spec": {
    
  },
  "status": {
    "phase": "Terminating"
  }

It should delete your namespace.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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