kubernetes强制删除namespace

1.执行命令删除namespace后一直显示Terminating,无法删除namespace

[root@10-21-20-71 kubesphere]# kubectl get ns
NAME                              STATUS        AGE
default                           Active        13d
dev                               Active        21h
istio-system                      Active        12d
kube-node-lease                   Active        13d
kube-public                       Active        13d
kube-system                       Active        13d
kubesphere-controls-system        Active        4d15h
kubesphere-devops-system          Active        18h
kubesphere-monitoring-federated   Active        4d10h
kubesphere-monitoring-system      Active        4d10h
kubesphere-system                 Terminating   4d9h

2.获取需要强制删除的NameSpace信息,并将图中所示的部分删除

[root@10-21-20-71 kubesphere]# kubectl get namespace kubesphere-system -o json > kubesphere-system.json 
1630385257922.jpg

3.运行kube-proxy

[root@10-21-20-71 kubesphere]# kubectl proxy --port=8081
Starting to serve on 127.0.0.1:8081

4.重新打开一个窗口通过API强制删除namespace

curl -k -H "Content-Type: application/json" -X PUT --data-binary @kubesphere-system.json http://127.0.0.1:8081/api/v1/namespaces/kubesphere-system/finalize
[root@10-21-20-71 kubesphere]# 
[root@10-21-20-71 kubesphere]# kubectl get ns
NAME                              STATUS   AGE
default                           Active   13d
dev                               Active   21h
istio-system                      Active   12d
kube-node-lease                   Active   13d
kube-public                       Active   13d
kube-system                       Active   13d
kubesphere-controls-system        Active   4d16h
kubesphere-devops-system          Active   19h
kubesphere-monitoring-federated   Active   4d10h
kubesphere-monitoring-system      Active   4d10h
[root@10-21-20-71 kubesphere]# 

你可能感兴趣的:(kubernetes强制删除namespace)