零、开启一个代理终端
kubectl proxy
Starting to serve on 127.0.0.1:8001
一、再开启一个操作终端
将要删除的namespace的配置文件输出保存
kubectl get ns ingress-nginx -o json > ingress.json
二、编辑Json文件,删除部分信息
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"cattle.io/status": "{\"Conditions\":[{\"Type\":\"ResourceQuotaInit\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-09-28T14:46:08Z\"},{\"Type\":\"InitialRolesPopulated\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-09-28T14:46:14Z\"}]}",
"field.cattle.io/projectId": "c-kzmm7:p-jlgtj",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"cattle-system\"}}\n",
"lifecycle.cattle.io/create.namespace-auth": "true"
},
"creationTimestamp": "2020-09-28T14:44:15Z",
"deletionTimestamp": "2021-01-20T14:31:38Z",
# "managedFields": [
# ......... #全删除
# ],
"name": "cattle-system",
"resourceVersion": "45489503",
"selfLink": "/api/v1/namespaces/cattle-system",
"uid": "57a925e7-781f-4eed-b1eb-3342d3ef835c"
##后面的全删除
}
}
三、调用接口删除
curl -k -H "Content-Type: application/json" -X PUT --data-binary @ingress.json http://127.0.0.1:8001/api/v1/namespaces/ingress-nginx/finalize
评论区