一直无法删除namespace
namespace一直处于
Terminating
状态
获取namespace的配置文件
kubectl get ns prom -o json > tmp.json
编辑namespace配置文件
原本的tmp.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"creationTimestamp": "2021-08-23T23:23:06Z",
"deletionTimestamp": "2021-08-23T23:28:11Z",
"labels": {
"kubernetes.io/metadata.name": "script"
},
"name": "script",
"resourceVersion": "495308",
"uid": "87d346af-fd7f-4cd0-8beb-fde3694f8273"
},
"spec": {
"finalizers": [
"kubernetes"
]
},
"status": {
"conditions": [
{
"lastTransitionTime": "2021-08-23T23:28:17Z",
"message": "All legacy kube types successfully parsed",
"reason": "ParsedGroupVersions",
"status": "False",
"type": "NamespaceDeletionGroupVersionParsingFailure"
},
],
"phase": "Terminating"
}
}
删除之后的tmp.json
删除spec、status部分的内容
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"creationTimestamp": "2021-08-23T23:23:06Z",
"deletionTimestamp": "2021-08-23T23:28:11Z",
"labels": {
"kubernetes.io/metadata.name": "script"
},
"name": "script",
"resourceVersion": "495308",
"uid": "87d346af-fd7f-4cd0-8beb-fde3694f8273"
}
}
启动代理
# 可以添加 --port 指定端口号
kubectl proxy
调用接口删除
# 这里要修改:保存的文件名,namespace的名字
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/script/finalize
查看结果
参考:https://blog.csdn.net/wangmiaoyan/article/details/104264277
评论区