欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

删除ns,一直处于Terminating状态中

程序员文章站 2022-04-18 17:12:57
...

问题一:删除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.

删除ns,一直处于Terminating状态中

解决办法:

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集群是携带认证的

删除ns,一直处于Terminating状态中

执行以下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

删除ns,一直处于Terminating状态中

删除ns,一直处于Terminating状态中

备注:

如果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哈,私信,大家一起交流

相关标签: kubernetes