签到成功

知道了

CNDBA社区CNDBA社区

k8s无法删除namespace

2023-06-10 20:20 745 0 原创 Docker
作者: hbhe0316

1.删除namespace的时候一直卡住,查看ns状态显示为Terminatinghttp://www.cndba.cn/hbhe0316/article/121048http://www.cndba.cn/hbhe0316/article/121048

[root@master elk]# kubectl get namespace
NAME                   STATUS        AGE
default                Active        26h
elastic-system         Terminating   13h
ingress-nginx          Active        26h
kube-logging           Terminating   6h1m
kube-node-lease        Active        26h
kube-public            Active        26h
kube-system            Active        26h
kubernetes-dashboard   Active        26h

2.导出namespace信息

kubectl get namespace elastic-system   -o json > /tmp/txt.json

3.修改/tmp/txt.json文件http://www.cndba.cn/hbhe0316/article/121048http://www.cndba.cn/hbhe0316/article/121048

   "spec": {
        "finalizers": [
            "kubernetes"
        ]
修改为
   "spec": {
        "finalizers": [
        ]

4.进入proxy模式http://www.cndba.cn/hbhe0316/article/121048

kubectl proxy --port=8081

5.curl调用删除namespacehttp://www.cndba.cn/hbhe0316/article/121048

cd /tmp
curl -k -H "Content-Type: application/json" -X PUT --data-binary @txt.json http://127.0.0.1:8081/api/v1/namespaces/elastic-system/finalize

6.再次查看

http://www.cndba.cn/hbhe0316/article/121048
http://www.cndba.cn/hbhe0316/article/121048http://www.cndba.cn/hbhe0316/article/121048http://www.cndba.cn/hbhe0316/article/121048

[root@master ~]#kubectl get ns
NAME                   STATUS        AGE
default                Active        26h
ingress-nginx          Active        26h
kube-logging           Terminating   6h8m
kube-node-lease        Active        26h
kube-public            Active        26h
kube-system            Active        26h
kubernetes-dashboard   Active        26h

版权声明:本文为博主原创文章,未经博主允许不得转载。

k8s

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1140772次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ