K8s namespace 处于Terminating状态的处理方法

############################################################################################

当前 namespace: kubernetes-dashboard /monitoring 显示terminating 不能删除

 

[root@k8s1 ~]#

[root@k8s1 ~]# kubectl get ns

NAME                   STATUS        AGE

ceph                   Active        15d

cephfs                 Active        7d3h

default                Active        22d

kube-node-lease        Active        22d

kube-public            Active        22d

kube-system            Active        22d

kube-util              Active        16d

kubernetes-dashboard   Terminating   21d

monitoring             Terminating   20d

###############################################################################################

解决办法:

 

启动一个proxy 8081端口

kubectl proxy跑一个API代理在本地的8081端口

 

[root@k8s1 ~]# nohup kubectl proxy --port=8081&

 

[root@k8s1 ~]# kubectl get namespace kubernetes-dashboard  -o json |jq '.spec = {"finalizers":[]}' >temp.json

 

[root@k8s1 ~]# curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8081/api/v1/namespaces/kubernetes-dashboard/finalize

[root@k8s1 ~]#

[root@k8s1 ~]#

[root@k8s1 ~]# kubectl get ns

NAME              STATUS        AGE

ceph              Active        15d

cephfs            Active        7d3h

default           Active        22d

kube-node-lease   Active        22d

kube-public       Active        22d

kube-system       Active        22d

kube-util         Active        16d

monitoring        Terminating   20d

[root@k8s1 ~]#

 

 

 

[root@k8s1 ~]#

[root@k8s1 ~]#

[root@k8s1 ~]#

[root@k8s1 ~]# kubectl get namespace monitoring  -o json |jq '.spec = {"finalizers":[]}' >temp01.json

[root@k8s1 ~]#  curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp01.json 127.0.0.1:8081/api/v1/namespaces/monitoring/finalize

{

  "kind": "Namespace",

  "apiVersion": "v1",

  "metadata": {

    "name": "monitoring",

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

    "uid": "ea316ed9-0c42-402b-b45d-aaa1bebafbf9",

    "resourceVersion": "3997654",

    "creationTimestamp": "2019-11-08T07:03:26Z",

    "deletionTimestamp": "2019-11-28T07:28:43Z"

  },

  "spec": {

   

  },

  "status": {

    "phase": "Terminating",

    "conditions": [

      {

        "type": "NamespaceDeletionDiscoveryFailure",

        "status": "True",

        "lastTransitionTime": "2019-11-28T07:28:48Z",

        "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": "2019-11-28T07:28:50Z",

        "reason": "ParsedGroupVersions",

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

      },

      {

        "type": "NamespaceDeletionContentFailure",

        "status": "False",

        "lastTransitionTime": "2019-11-28T07:31:00Z",

        "reason": "ContentDeleted",

        "message": "All content successfully deleted"

      }

    ]

  }

}[root@k8s1 ~]#

[root@k8s1 ~]#

[root@k8s1 ~]# kubectl get ns

NAME              STATUS   AGE

ceph              Active   15d

cephfs            Active   7d3h

default           Active   22d

kube-node-lease   Active   22d

kube-public       Active   22d

kube-system       Active   22d

kube-util         Active   16d

[root@k8s1 ~]#

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值