kubernetes删除Terminating的pod

#环境

  • os: CentOS 7
  • pc: VirtualBox

#描述
创建的dashboard pod无法删除

#修复
使用–grace-period=0 –force 参数
参见官方文档
https://kubernetes.io/docs/tasks/run-application/force-delete-stateful-set-pod/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
[root@k8s-master ~]# kubectl get all -n kube-system
NAME READY STATUS RESTARTS AGE
pod/calico-etcd-7jdbr 1/1 Running 0 22h
pod/calico-kube-controllers-685755779f-wvh48 1/1 Running 0 22h
pod/calico-node-mg7j2 2/2 Running 1 22h
pod/calico-node-mjggr 2/2 Running 1 22h
pod/etcd-k8s-master 1/1 Running 0 22h
pod/kube-apiserver-k8s-master 1/1 Running 0 22h
pod/kube-controller-manager-k8s-master 1/1 Running 0 22h
pod/kube-dns-86f4d74b45-clw69 2/3 Running 210 22h
pod/kube-proxy-jks5s 1/1 Running 0 22h
pod/kube-proxy-xl2b7 1/1 Running 0 22h
pod/kube-scheduler-k8s-master 1/1 Running 0 22h
pod/kubernetes-dashboard-5d676fccd5-2vwnx 1/1 Terminating 77 20h
pod/kubernetes-dashboard-7d5dcdb6d9-j7m75 1/1 Terminating 0 21h
pod/kubernetes-dashboard-7d5dcdb6d9-lxlvn 1/1 Terminating 11 22h
pod/kubernetes-dashboard-f56559df6-4bjj5 1/1 Terminating 205 5h
...
[root@k8s-master ~]# kubectl -n kube-system delete $(kubectl -n kube-system get pod -o name | grep dashboard) --grace-period=0 --force
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.
pod "kubernetes-dashboard-5d676fccd5-2vwnx" deleted
pod "kubernetes-dashboard-7d5dcdb6d9-j7m75" deleted
pod "kubernetes-dashboard-7d5dcdb6d9-lxlvn" deleted
pod "kubernetes-dashboard-f56559df6-4bjj5" deleted
[root@k8s-master ~]# kubectl get all -n kube-system
NAME READY STATUS RESTARTS AGE
pod/calico-etcd-7jdbr 1/1 Running 0 22h
pod/calico-kube-controllers-685755779f-wvh48 1/1 Running 0 22h
pod/calico-node-mg7j2 2/2 Running 1 22h
pod/calico-node-mjggr 2/2 Running 1 22h
pod/etcd-k8s-master 1/1 Running 0 22h
pod/kube-apiserver-k8s-master 1/1 Running 0 22h
pod/kube-controller-manager-k8s-master 1/1 Running 0 22h
pod/kube-dns-86f4d74b45-clw69 2/3 Running 210 22h
pod/kube-proxy-jks5s 1/1 Running 0 22h
pod/kube-proxy-xl2b7 1/1 Running 0 22h
pod/kube-scheduler-k8s-master 1/1 Running 0 22h
坚持原创技术分享,您的支持将鼓励我继续创作!