• Kubernetes删除一直处于Terminating状态的namespace


    问题现象:

    删除namespace,一直处于Terminating,并且用--force --grace-period=0 也删除不了

    develop       Terminating   4d9h

    Error from server (Conflict): error when deleting "ns.yaml": Operation cannot be fulfilled on namespaces "develop": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.

    解决方案:

    Step1:查看namespace 是否还是Terminating

     kubectl get namespaces

    Step2: 查看yaml文件 ,finalizers是 - kubernetes

     kubectl get namespace <terminating-namespace> -o yaml
     apiVersion: v1
     kind: Namespace
     metadata:
       creationTimestamp: 2020-05-20T18:48:30Z
       deletionTimestamp: 2020-05-20T18:59:36Z
       name: develop
       resourceVersion: "1385077"
       selfLink: /api/v1/namespaces/<terminating-namespace>
       uid: b50c9ea4-ec2b-11e8-a0be-fa163eeb47a5
     spec:
       finalizers:
       - kubernetes
     status:
       phase: Terminating

    Step3:获取namespace的json文件

     kubectl get namespace <terminating-namespace> -o json >tmp.json
     {
          "apiVersion": "v1",
          "kind": "Namespace",
          "metadata": {
              "creationTimestamp": "2020-05-20T18:48:30Z",
              "deletionTimestamp": "2020-05-20T18:59:36Z",
              "name": "<terminating-namespace>",
              "resourceVersion": "1385077",
              "selfLink": "/api/v1/namespaces/<terminating-namespace>",
              "uid": "b50c9ea4-ec2b-11e8-a0be-fa163eeb47a5"
          },
          "spec": {
             "finalizers": 
          },
          "status": {
              "phase": "Terminating"
          }
      }

    Step4:修改json文件,将finalizers去掉

    {
        "apiVersion": "v1",
        "kind": "Namespace",
        "metadata": {
            "annotations": {
                "scheduler.alpha.kubernetes.io/node-selector": "scen=kuai-develop,user=kuai-all"
            },
            "creationTimestamp": "2020-05-20T05:30:21Z",
            "deletionTimestamp": "2020-05-20T04:22:14Z",
            "name": "develop",
            "resourceVersion": "388130567",
            "selfLink": "/api/v1/namespaces/kuai-develop",
            "uid": "2b967bf4-966d-11ea-885f-246e967d5d94"
        },
        "spec": {
        },
        "status": {
            "phase": "Terminating"
        }
    }

    Step5:执行命令

    curl -k -H "Authorization: Bearer ${token}" -H "Content-Type: application/json" -X PUT --data-binary @tmp.json https://10.196.0.1:443/api/v1/namespaces/${namespace}/finalize

    参考:https://www.ibm.com/support/knowledgecenter/en/SSBS6K_3.1.1/troubleshoot/ns_terminating.html

  • 相关阅读:
    Linux系统备份与恢复
    CentOS7修改设置静态IP和DNS
    CentOS系统基础优化16条知识汇总
    CentOS英文提示修改为中文提示的方法
    CentOS修改主机名和网络信息
    CentOS 7系统查看系统版本和机器位数
    Linux下设置SSH Server设置时间链接限制
    查看Linux下系统资源占用常用命令(top、free、uptime)
    查看CentOS系统运行了多久使用uptime命令
    设计模式(七)学习----命令模式
  • 原文地址:https://www.cnblogs.com/shix0909/p/12921380.html
Copyright © 2020-2023  润新知