本文主要是介绍K8s 删除命名空间 namespace ,命令空间会一直 terminating,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
第一种方式:
kubectl proxy
kubectl get namespace istio-system -o json | jq 'del(.spec.finalizers[] | select("kubernetes"))' | curl -s -k -H "Content-Type: application/json" -X PUT -o /dev/null --data-binary @- http://localhost:8001/api/v1/namespaces/istio-system/finalize
第二种方式:
比如说 kubectl delete istio-operator 命名空间后,一直处于 terminating 。。。
kubectl get ns istio-operator -o json > delete-ns.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"labels\":{\"install.operator.istio.io/owning-resource\":\"\",\"istio-injection\":\"disabled\",\"istio-operator-managed\":\"Reconcile\",\"operator.istio.io/component\":\"IstioOperator\",\"operator.istio.io/managed\":\"Reconcile\",\"operator.istio.io/version\":\"1.6.0\"},\"name\":\"istio-operator\"}}\n"
},
"creationTimestamp": "2020-07-22T07:40:17Z",
"labels": {
"install.operator.istio.io/owning-resource": "",
"istio-injection": "disabled",
"istio-operator-managed": "Reconcile",
"operator.istio.io/component": "IstioOperator",
"operator.istio.io/managed": "Reconcile",
"operator.istio.io/version": "1.6.0"
},
"name": "istio-operator",
"resourceVersion": "176004",
"selfLink": "/api/v1/namespaces/istio-operator",
"uid": "0d14ab93-14b1-4aa8-98a5-450bb5b84ae1"
},
"spec": {
"finalizers": [
"kubernetes"
]
},
"status": {
"phase": "Active"
}
}
将 spec 中的内容清空
在一个终端 kubectl proxy 开启代理
curl -k -H "Content-Type: application/json" -X PUT --data-binary @delete-ns.json http://127.0.0.1:8081/api/v1/namespaces/istio-operator/finalize
然后命令空间就会被删除啦
这篇关于K8s 删除命名空间 namespace ,命令空间会一直 terminating的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!