怎样使用K8S强制删除namespace
【删除namespace一直处于Terminating状态】:
创建api proxy:
root@master30:~# kubectl proxy --port=8001
Starting to serve on 127.0.0.1:8001
把ns追加到json文件:
kubectl get namespace 你的命名空间 -o json |jq '.spec = {"finalizers":[]}' >temp.json
调用api删除:
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/你的命名空间/finalize
root@master30:~# kubectl get ns
NAME STATUS AGE
default Active 22d
ingress-nginx Active 22d
istio-system Active 21d
kube-node-lease Active 22d
kube-public Active 22d
kube-system Active 22d
创建api proxy:
root@master30:~# kubectl proxy --port=8001
Starting to serve on 127.0.0.1:8001
把ns追加到json文件:
kubectl get namespace 你的命名空间 -o json |jq '.spec = {"finalizers":[]}' >temp.json
调用api删除:
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/你的命名空间/finalize
root@master30:~# kubectl get ns
NAME STATUS AGE
default Active 22d
ingress-nginx Active 22d
istio-system Active 21d
kube-node-lease Active 22d
kube-public Active 22d
kube-system Active 22d