K8S 中强制删除namespace 命名空间后 显示 Terminating 状态。
并且报错 warning: Immediate deletion does not wait for confirmation that the running
故障现象:
[root@master-1 ~]# kubectl delete ns mysql –force –grace-period=0
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
[root@master-1 ~]# kubectl get ns
NAME STATUS AGE
default Active 67d
efk Active 21h
ingress-nginx Active 59d
kube-node-lease Active 67d
kube-public Active 67d
kube-system Active 67d
kubernetes-dashboard Active 67d
ms Active 40d
mysql Terminating 42d
解决方法:
[root@master-1 ~]# kubectl get ns mysql -o json > mysql.json
删除其中的spec字段,因为k8s集群是携带认证的
[root@master-1 ~]# vim mysql.json
删除spec字段后,执行以下curl命令,使用kube-apiserver的8080端口,执行删除操作
#注意修改@XXX.json ,修改 namespaces/XXX/finalize ,其中XXX 表示你要删除的命名空间名称
[root@master-1 ~]# curl -k -H "Content-Type: application/json" -X PUT --data-binary @mysql.json http://127.0.0.1:8080/api/v1/namespaces/mysql/finalize
再次查看ns
NAME STATUS AGE
default Active 67d
efk Active 21h
ingress-nginx Active 59d
kube-node-lease Active 67d
kube-public Active 67d
kube-system Active 67d
kubernetes-dashboard Active 67d
ms Active 40d
备注:
如果kube-apiserver未开非安全端口,可以手动创建一个代理会话
# kubectl proxy –port=8081
# curl -k -H “Content-Type: application/json” -X PUT –data-binary @test.json http://127.0.0.1:8081/api/v1/namespaces/test/finalize
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容