在工作中遇到了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 <ns>
指定
kubectl delete statefulsets <statefulset name> --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 <pod name> --force --grace-period=0