问题描述$ kubectl get namespaces
NAME STATUS AGE
cephfs Active 147d
default Active 154d
kube-node-lease Active 62d
kube-public Active 154d
kube-system Active 154d
monitoring Terminating 7d20h
$ kubectl delete namespaces monitoring --grace-period=0 --force
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
Error from server (Conflict): Operation cannot be fulfilled on namespaces "monitoring": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.
解决办法$ kubectl get namespaces monitoring -o json > tmp.json
$ vim tmp.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"monitoring\"}}\n"
},
"creationTimestamp": "2019-10-31T09:09:27Z",
"deletionTimestamp": "2019-11-08T03:19:50Z",
"name": "monitoring",
"resourceVersion": "26367884",
"selfLink": "/api/v1/namespaces/monitoring",
"uid": "23c34de1-fbbe-11e9-adc9-005056a85a7c"
},
"spec": {
"finalizers": [
....//删除这里的内容
]
},
"status": {
"phase": "Terminating"
}
}
$ kubectl proxy --port=8081
Starting to serve on 127.0.0.1:8081
$ curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8081/api/v1/namespaces/monitoring/finalize
$ kubectl get namespaces
NAME STATUS AGE
cephfs Active 147d
default Active 154d
kube-node-lease Active 62d
kube-public Active 154d
kube-system Active 154d