k8s 删除 ingress-nginx namespace长时间处于Terminating

问题重现

通过 kubectl delete -f namespace.yaml删除后1小时ingress-nginx命名空间一直处于Terminating 状态

#通过声明文件的方式删除ingress-nginx
 kubectl delete -f namespace.yaml
 #删除过后差不多一小时ingress-nginx还是处有Terminating状态
 [root@app1 v0.17.0]# kubectl get ns
NAME                           STATUS        AGE
default                        Active        2y196d
ingress-nginx                  Terminating   2y194d
kube-node-lease                Active        2y180d
kube-public                    Active        2y196d
kube-system                    Active        2y196d
kubesphere-controls-system     Active        283d
kubesphere-monitoring-system   Active        283d
kubesphere-system              Active        125d

如图
在这里插入图片描述

导出ingress-nginx当前运行的配置属性文件

# 导出 namespace声明json 配置
kubectl get ns ingress-nginx -o json > tmp.json

文件内容入下

{
  "kind": "Namespace",
  "apiVersion": "v1",
  "metadata": {
    "name": "ingress-nginx",
    "selfLink": "/api/v1/namespaces/ingress-nginx/finalize",
    "uid": "38622502-7366-11ea-968d-00163e025af8",
    "resourceVersion": "255024610",
    "creationTimestamp": "2020-03-31T15:42:25Z",
    "deletionTimestamp": "2022-10-12T10:56:47Z",
    "deletionGracePeriodSeconds": 0,
    "labels": {
      "app.kubernetes.io/name": "ingress-nginx",
      "app.kubernetes.io/part-of": "ingress-nginx",
      "kubesphere.io/namespace": "ingress-nginx"
    },
    "annotations": {
      "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"labels\":{\"app.kubernetes.io/name\":\"ingress-nginx\",\"app.kubernetes.io/part-of\":\"ingress-nginx\"},\"name\":\"ingress-nginx\"}}\n"
    },
    "finalizers": [
    	 "finalizers.kubesphere.io/namespaces"
    ]
  },
  "spec": {
    
  },
  "status": {
    "phase": "Terminating",
    "conditions": [
      {
        "type": "NamespaceDeletionDiscoveryFailure",
        "status": "False",
        "lastTransitionTime": "2022-10-12T10:56:52Z",
        "reason": "ResourcesDiscovered",
        "message": "All resources successfully discovered"
      },
      {
        "type": "NamespaceDeletionGroupVersionParsingFailure",
        "status": "False",
        "lastTransitionTime": "2022-10-12T10:56:52Z",
        "reason": "ParsedGroupVersions",
        "message": "All legacy kube types successfully parsed"
      },
      {
        "type": "NamespaceDeletionContentFailure",
        "status": "False",
        "lastTransitionTime": "2022-10-12T10:56:52Z",
        "reason": "ContentDeleted",
        "message": "All content successfully deleted, may be waiting on finalization"
      },
      {
        "type": "NamespaceContentRemaining",
        "status": "False",
        "lastTransitionTime": "2022-10-12T10:56:52Z",
        "reason": "ContentRemoved",
        "message": "All content successfully removed"
      },
      {
        "type": "NamespaceFinalizersRemaining",
        "status": "False",
        "lastTransitionTime": "2022-10-12T10:56:52Z",
        "reason": "ContentHasNoFinalizers",
        "message": "All content-preserving finalizers finished"
      }
    ]
  }
}

通过向api-server发送http请求强制删除

# 开启代理端口
[root@app1 v0.17.0]# kubectl proxy
Starting to serve on 127.0.0.1:8001

#通过刚开启的代理端口8001发起请求(注意该请求一定要到刚生成tmp.json文件目录)
 curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/ingress-nginx/finalize
 

接口返回结果
在这里插入图片描述

发现问题还是未解决

在次查看发现ingress-nginx还是Terminating

 [root@app1 v0.17.0]# kubectl get ns
NAME                           STATUS        AGE
default                        Active        2y196d
ingress-nginx                  Terminating   2y194d
kube-node-lease                Active        2y180d
kube-public                    Active        2y196d
kube-system                    Active        2y196d
kubesphere-controls-system     Active        283d
kubesphere-monitoring-system   Active        283d
kubesphere-system              Active        125d

最后通过各种查资料发现要清空spec字段内容以及finalizers字段内容
发现finalizers没有清空
在这里插入图片描述
删除过后的文件
在这里插入图片描述
再次发起http请求,发现删除成功

#再次发起删除请求
 curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/ingress-nginx/finalize
#查看删除成功
 [root@app1 v0.17.0]# kubectl get ns
default                        Active   2y196d
kube-node-lease                Active   2y180d
kube-public                    Active   2y196d
kube-system                    Active   2y196d
kubesphere-controls-system     Active   283d
kubesphere-monitoring-system   Active   283d
kubesphere-system              Active   125d
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值