以名称空间monitoring为例
kubectl proxy
生成资源清单文件tmp.josn
kubectl get ns monitoring -o json > tmp.json
删除spec字段
{ "apiVersion": "v1", "kind": "Namespace", "metadata": { "annotations": { "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"monitoring\"}}\n" }, "creationTimestamp": "2021-04-30T08:13:01Z", "deletionTimestamp": "2021-04-30T08:22:56Z", "name": "monitoring", "resourceVersion": "35696", "selfLink": "/api/v1/namespaces/monitoring", "uid": "e15a37d4-a98b-11eb-900f-fa163e5df06c" }, "status": { "phase": "Terminating" } }
向APIserver发送删除请求
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json 127.0.0.1:8001/api/v1/namespaces/monitoring/finalize