k8s 删除 ingress-nginx namespace长时间处于Terminating
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
更多推荐
已为社区贡献3条内容
所有评论(0)