一、现象
当删除命名空间后,发现该空间一直处于Terminating状态
[root@imanager-beta-arm-21756-5g5ap ~]# kubectl get ns
NAME STATUS AGE
default Active 48m
kube-public Active 48m
kube-system Active 48m
supermap Terminating 37m
二、强制删除流程
2.1 新开启一个窗口,启动一个进程
kubectl proxy --port=8081
2.2 导出当前命名空间json
kubectl get ns supermap -o json > supermap.json
2.3 打开导出的json文件,并将spec字段设置为空,如下最终结果
[root@imanager-beta-arm-21756-5g5ap ~]# cat supermap.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"creationTimestamp": "2020-07-22T01:04:57Z",
"deletionTimestamp": "2020-07-22T01:24:34Z",
"name": "supermap",
"resourceVersion": "6656",
"selfLink": "/api/v1/namespaces/supermap",
"uid": "5bfc29b1-cbb7-11ea-a69c-fa163efc4ca9"
},
"spec": {
},
"status": {
"phase": "Terminating"
}
}
2.4 通过发送请求的方式进行删除
curl -k -H "Content-Type:application/json" -X PUT --data-binary @supermap.json http://127.0.0.1:8081/api/v1/namespaces/supermap/finalize
其中
- supermap.json 是我们导出的文件
- supermap 是需要删除的命名空间
2.5 执行删除命令返回文件内容
[root@imanager-beta-arm-21756-5g5ap ~]# curl -k -H "Content-Type:application/json" -X PUT --data-binary @supermap.json http://127.0.0.1:808/api/v1/namespaces/supermap/finalize
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "supermap",
"selfLink": "/api/v1/namespaces/supermap/finalize",
"uid": "5bfc29b1-cbb7-11ea-a69c-fa163efc4ca9",
"resourceVersion": "11000",
"creationTimestamp": "2020-07-22T01:04:57Z",
"deletionTimestamp": "2020-07-22T01:24:34Z"
},
"spec": {
},
"status": {
"phase": "Terminating"
}
}
2.6 最后再次检查命名空间,Terminating状态已被删除
[root@imanager-beta-arm-21756-5g5ap ~]#kubectl get ns
NAME STATUS AGE
default Active 53m
kube-public Active 53m
kube-system Active 53m
(转发请注明出处:https://www.jianshu.com/u/829cbce64381 如发现有错,请留言,谢谢)