本文章已发布到个人博客:https://www.niewx.cn/
1. kubectl get ns 查看处于Terminating的ns
代码语言:javascript复制[root@VM_1_4_centos ~]# kubectl get ns | grep testns
testns Terminating 21d
2. 将处于Terminating的ns的描述文件保存下来
代码语言:javascript复制[root@VM_1_4_centos ~]# kubectl get ns testns -o json > tmp.json
[root@VM_1_4_centos ~]# cat tmp.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"creationTimestamp": "2020-10-13T14:28:07Z",
"name": "testns",
"resourceVersion": "13782744400",
"selfLink": "/api/v1/namespaces/testns",
"uid": "9ff63d71-a4a1-43bc-89e3-78bf29788844"
},
"spec": {
"finalizers": [
"kubernetes"
]
},
"status": {
"phase": "Terminating"
}
}
3. 本地启动kube proxy
代码语言:javascript复制kubectl proxy --port=8081
4. 新开窗口执行删除操作
代码语言:javascript复制curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8081/api/v1/namespaces/testns/finalize