k8s删除namespace失败,状态Terminating解决方案

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"
  }
}

删除成功

猜你喜欢

转载自www.cnblogs.com/zhangzhi19861216/p/12591345.html