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

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

1569828679697

解决办法:

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

1569828938584

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

1569829237653

1569829253110

备注:

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

  • 7
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值