强制删除异常pod和namespace

2022-04-06  本文已影响0人  玄德公笔记

1. 删除异常pod

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

2. 删除异常namespace

说明:删除Terminatin状态的namespace

2.1 现象

[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
[root@devops-master ~]# kubectl get all -n iot-01
No resources found.

2.2解决

[root@devops-master ~]# kubectl edit namespaces iot-01
  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
[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
上一篇 下一篇

猜你喜欢

热点阅读