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已經被刪除


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM