問題一:刪除ns,一直處於Terminating狀態中
強制刪除也是出現報錯
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 "devtesting": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.
解決辦法:
kubectl get namespace devtesting -o json > devtesting.json
# cat devtesting.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"cattle.io/status": "{"Conditions":[{"Type":"ResourceQuotaInit","Status":"True","Message":"","LastUpdateTime":"2019-09-23T07:24:02Z"},{"Type":"InitialRolesPopulated","Status":"True","Message":"","LastUpdateTime":"2019-09-23T07:24:02Z"}]}",
"lifecycle.cattle.io/create.namespace-auth": "true"
},
"creationTimestamp": "2019-09-23T07:23:03Z",
"deletionTimestamp": "2019-09-30T06:35:09Z",
"labels": {
"name": "devtesting"
},
"name": "devtesting",
"resourceVersion": "6153812",
"selfLink": "/api/v1/namespaces/devtesting",
"uid": "a00e013b-0066-4b64-915d-05acde5c9a09"
},
"spec": {
"finalizers": [
"kubernetes"
]
},
"status": {
"phase": "Terminating"
}
}
刪除其中的spec字段,因為k8s集群是攜帶認證的
執行以下curl命令,使用kube-apiserver的8080端口,執行刪除操作
curl -k -H "Content-Type: application/json" -X PUT --data-binary @devtesting.json http://127.0.0.1:8080/api/v1/namespaces/devtesting/finalize
備註:
如果kube-apiserver未開非安全端口,可以手動創建一個代理會話,
# kubectl proxy --port=8081
# curl -k -H "Content-Type: application/json" -X PUT --data-binary @devtesting.json http://127.0.0.1:8081/api/v1/namespaces/test/finalize
如果有其他不明白的可以關注我私人博客www.zqliublog.com哈,私信,大家一起交流