Namespace 状态-Terminating 删除不掉

删除不掉的Namespace解决方法

kubectl get namespace cattle-system -o json > tmp.json
# tmp.json内容为
{
  "apiVersion": "v1",
  "kind": "Namespace",
  "metadata": {
    "annotations": {
      "cattle.io/status": "{\"Conditions\":[{\"Type\":\"ResourceQuotaInit\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-06-03T08:03:36Z\"},{\"Type\":\"InitialRolesPopulated\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-06-03T08:03:41Z\"}]}",
      "field.cattle.io/projectId": "c-lwpkf:p-9fxtj",
      "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"cattle-system\"}}\n",
      "lifecycle.cattle.io/create.namespace-auth": "true"
    },
    "creationTimestamp": "2020-06-03T08:03:33Z",
    "deletionGracePeriodSeconds": 0,
    "deletionTimestamp": "2020-06-03T08:09:42Z",
    "finalizers": [
      "controller.cattle.io/namespace-auth" # 删除该行
    ],
    "labels": {
      "field.cattle.io/projectId": "p-9fxtj"
    },
    "name": "cattle-system",
    "resourceVersion": "70201880",
    "selfLink": "/api/v1/namespaces/cattle-system",
    "uid": "403698bc-01d7-4496-b2a3-a426e66c51f1"
  },
  "spec": {
    "finalizers": []
  },
  "status": {
    "conditions": [
      {
        "lastTransitionTime": "2020-06-03T08:09:48Z",
        "message": "All resources successfully discovered",
        "reason": "ResourcesDiscovered",
        "status": "False",
        "type": "NamespaceDeletionDiscoveryFailure"
      },
      {
        "lastTransitionTime": "2020-06-03T08:09:48Z",
        "message": "All legacy kube types successfully parsed",
        "reason": "ParsedGroupVersions",
        "status": "False",
        "type": "NamespaceDeletionGroupVersionParsingFailure"
      },
      {
        "lastTransitionTime": "2020-06-03T08:09:48Z",
        "message": "All content successfully deleted",
        "reason": "ContentDeleted",
        "status": "False",
        "type": "NamespaceDeletionContentFailure"
      }
    ],
    "phase": "Terminating"
  }
}

删除finalizers 字段中的内容

克隆新会话

kubectl proxy --port=8081

修改配置

curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8081/api/v1/namespaces/cattle-system/finalize

kubectl get ns获取发现该ns已经被删除

posted @ 2020-06-04 16:13  ruixing  阅读(1008)  评论(1编辑  收藏  举报