天天看点

k8s的namespace一直Terminating-已解决

1.创建demo

kubectl create ns test

namespace/test created

2.删除demo namespace

kubectl delete ns test

namespace "test" deleted

一直处于deleted不见exit

3.查看状态 可见test namespace 处于Terminating

kubectl get ns -w

NAME STATUS AGE

test Terminating 18s

4.下面给出一种完美的解决方案:调用接口删除

开启一个代理终端

kubectl proxy

Starting to serve on 127.0.0.1:8001

5.再开启一个操做终端

将test namespace的配置文件输出保存

kubectl get ns test -o json > test.json

6.删除spec及status部分的内容还有metadata字段后的","号,切记!

剩下内容大体以下
{
    "apiVersion": "v1",

    "kind": "Namespace",

    "metadata": {

        "annotations": {

            "cattle.io/status": "{\"Conditions\":[{\"Type\":\"ResourceQuotaInit\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:17Z\"},{\"Type\":\"InitialRolesPopulated\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:18Z\"}]}",

            "lifecycle.cattle.io/create.namespace-auth": "true"

        },

        "creationTimestamp": "2020-10-09T07:12:16Z",

        "deletionTimestamp": "2020-10-09T07:12:22Z",

        "name": "test",

        "resourceVersion": "471648079",

        "selfLink": "/api/v1/namespaces/test",

        "uid": "862d311e-d87a-48c2-bc48-332a4db9dbdb"

    }

}
           

7.调接口删除

{

  "kind": "Namespace",

  "apiVersion": "v1",

  "metadata": {

    "name": "test",

    "selfLink": "/api/v1/namespaces/test/finalize",

    "uid": "862d311e-d87a-48c2-bc48-332a4db9dbdb",

    "resourceVersion": "471648079",

    "creationTimestamp": "2020-10-09T07:12:16Z",

    "deletionTimestamp": "2020-10-09T07:12:22Z",

    "annotations": {

      "cattle.io/status": "{\"Conditions\":[{\"Type\":\"ResourceQuotaInit\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:17Z\"},{\"Type\":\"InitialRolesPopulated\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:18Z\"}]}",

      "lifecycle.cattle.io/create.namespace-auth": "true"

    }

  },

  "spec": {

  },

  "status": {

    "phase": "Terminating",

    "conditions": [

      {

        "type": "NamespaceDeletionDiscoveryFailure",

        "status": "True",

        "lastTransitionTime": "2020-10-09T07:12:27Z",

        "reason": "DiscoveryFailed",

        "message": "Discovery failed for some groups, 1 failing: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request"

      },

      {

        "type": "NamespaceDeletionGroupVersionParsingFailure",

        "status": "False",

        "lastTransitionTime": "2020-10-09T07:12:28Z",

        "reason": "ParsedGroupVersions",

        "message": "All legacy kube types successfully parsed"

      },

      {

        "type": "NamespaceDeletionContentFailure",

        "status": "False",

        "lastTransitionTime": "2020-10-09T07:12:28Z",

        "reason": "ContentDeleted",

        "message": "All content successfully deleted"

      }

    ]
  }
}
           

8.查看结果