强制删除Statefulset及其中Pod

在工作中遇到了statefulset不能正常删除的问题,命令一直挂起不能执行得到结果,比如:

kubectl delete statefulset is-en-conductor
[root@opsft-lb-1 OpenShift] oc get all
NAME                             DESIRED   CURRENT   AGE
statefulsets/is-en-conductor     0         1         5h
statefulsets/is-engine-compute   0         2         5h

NAME                     READY     STATUS        RESTARTS   AGE
po/is-en-conductor-0     0/1       Terminating   2          1h
po/is-engine-compute-0   1/1       Running       0          5h
po/is-engine-compute-1   0/1       Terminating   0          5h

解决办法如下,如果在其他namespace中,注意用-n 指定

kubectl delete statefulsets  --force --grace-period=0 --cascade=false

然后逐个删除挂起的pod:

NAME                     READY     STATUS        RESTARTS   AGE
po/is-en-conductor-0     0/1       Terminating   2          1h
po/is-engine-compute-0   1/1       Running       0          5h
po/is-engine-compute-1   0/1       Terminating   0          5h
kubectl delete pod  --force --grace-period=0

你可能感兴趣的:(强制删除Statefulset及其中Pod)