在Kubernetes
上删除pod时,简单的delete
有时不起作用,那么就会用到强制删除,
但是强制删除有时又会发生一些比较奇怪的现象。
强制删除pod
kubectl delete pod -n istio-system xx --grace-period=0 --force
xx
是pod name
奇怪的现象
强制删除有时会有警告出现,并且删完之后,立刻又冒出来一个
[root@iZwz983wql3f1yerh738xeZ jaeger]# kubectl get pods -n istio-system
NAME READY STATUS RESTARTS AGE
jaeger-deployment-7f98f999cd-4vwjc 1/1 Running 0 13m
[root@iZwz983wql3f1yerh738xeZ jaeger]# kubectl delete pod -n istio-system jaeger-deployment-7f98f999cd-4vwjc --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 "jaeger-deployment-7f98f999cd-4vwjc" deleted
[root@iZwz983wql3f1yerh738xeZ jaeger]# kubectl get pods -n istio-system
NAME READY STATUS RESTARTS AGE
jaeger-deployment-7f98f999cd-2pmmb 0/1 Running 0 2s
可以看到删除jaeger-deployment-7f98f999cd-4vwjc
之后,
又冒出来一个jaeger-deployment-7f98f999cd-2pmmb
删除这个冒出来的,又会出现另一个。。。
谷歌了一下,找到了一个方法
[root@iZwz983wql3f1yerh738xeZ jaeger]# kubectl get deployments -n istio-system
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
jaeger-deployment 1 1 1 1 1d
[root@iZwz983wql3f1yerh738xeZ jaeger]# kubectl delete deployment -n istio-system jaeger-deployment --force --grace-period=0
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.
deployment.extensions "jaeger-deployment" deleted
[root@iZwz983wql3f1yerh738xeZ jaeger]# kubectl get deployments -n istio-system
No resources found.
[root@iZwz983wql3f1yerh738xeZ jaeger]# kubectl get pods -n istio-system
No resources found.
Solution
所以解决方法是:(注意替换namespace
和name
哦)
kubectl get deployments -n istio-system
kubectl delete deployment -n istio-system jaeger-deployment --force --grace-period=0
kubectl get deployments -n istio-system
kubectl get pods -n istio-system