获取Terminating状态的namespace
~ kubectl get namespace
NAME STATUS AGE
bluehelix Active 146d
broker Active 146d
cattle-fleet-clusters-system Active 87d
cert-manager Terminating 87d
查询要删除的namespace下是否还有资源
~ kubectl get all -n cert-manager
No resources found in cert-manager namespace.
导出为json
~ kubectl get ns cert-manager -o json > cert-manager.json
删除json文件中的finalize关键字字段
vim cert-manager.json
删除前
"spec": {
"finalizers": [
"kubernetes"
]
},
删除后
"spec": {
"finalizers": []
},
开启 proxy
~ kubectl proxy
Starting to serve on 127.0.0.1:8001
另起终端 指定刚才的json文件 执行以下命令进行删除操作
curl -k -H "Content-Type: application/json" -X PUT --data-binary @cert-manager.json http://127.0.0.1:8001/api/v1/namespaces/cert-manager/finalize
再次获取namespace状态,删除成功
~ kubectl get namespace
NAME STATUS AGE
bluehelix Active 146d
broker Active 146d
cattle-fleet-clusters-system Active 87d
kubectl edit ns cert-manager
原文链接
https://blog.csdn.net/ma_qi_chao/article/details/135022175