美文网首页
强制删除异常pod和namespace

强制删除异常pod和namespace

作者: 玄德公笔记 | 来源:发表于2022-04-06 11:37 被阅读0次

1. 删除异常pod

kubectl delete pod xxxx --force --grace-period=0

2. 删除异常namespace

说明:删除Terminatin状态的namespace

2.1 现象

  • 如下,iot-01 和iot-02两个namespace删除后,一直处于Terminating状态
[root@devops-master ~]# kubectl get namespaces
NAME                        STATUS        AGE
cattle-prometheus-p-5pn7p   Active        97m
cattle-system               Active        252d
default                     Active        252d
iot-01                      Terminating   249d
iot-02                      Terminating   228d
iot-test-01                 Active        6d19h
iot-test-03                 Active        20h
  • 查看namespace下没有任何对象了
[root@devops-master ~]# kubectl get all -n iot-01
No resources found.

2.2解决

  • 进入编译
[root@devops-master ~]# kubectl edit namespaces iot-01
  • 将finalizers注释掉,并保存修改
  creationTimestamp: "2019-08-15T05:38:52Z"
  deletionGracePeriodSeconds: 0
  deletionTimestamp: "2020-04-20T05:52:38Z"
#  finalizers:
#  - finalizers.kubesphere.io/namespaces
  labels:
    cattle.io/creator: norman
    field.cattle.io/projectId: p-cmbs8
  name: iot-01
  resourceVersion: "53801851"
  selfLink: /api/v1/namespaces/iot-01
  uid: 3061673c-dcd9-4442-80ae-0cd438d7df86
spec: {}
status:
  phase: Terminating
  • 验证
    iot-01 被删除了
[root@devops-master ~]# kubectl get namespaces
NAME                        STATUS        AGE
cattle-prometheus-p-5pn7p   Active        97m
cattle-system               Active        252d
default                     Active        252d
iot-02                      Terminating   228d
iot-test-01                 Active        6d19h
iot-test-03                 Active        20h

相关文章

网友评论

      本文标题:强制删除异常pod和namespace

      本文链接:https://www.haomeiwen.com/subject/lnersrtx.html