k8s 刪除namespace失敗(強制刪除也是出現報錯),狀態Terminating,如下:
kubectl delete namespace k8s-springboot
Error from server (Conflict): Operation cannot be fulfilled on namespaces "k8s-springboot": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.
解決方案,刪除其中的spec字段,因為k8s集群是攜帶認證的:
1,導出信息
kubectl get namespace k8s-springboot -o json > tmp.json
2,刪除spec
3,執行
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/k8s-springboot/finalize
結果:
{ "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "k8s-springboot", "selfLink": "/api/v1/namespaces/k8s-springboot/finalize", "uid": "44f3c5b5-709e-11ea-963c-025000000001", "resourceVersion": "3213373", "creationTimestamp": "2020-03-28T02:46:05Z", "deletionTimestamp": "2020-03-28T04:29:55Z" }, "spec": { }, "status": { "phase": "Terminating" } }
刪除成功