k8s中正确删除一个pod

1、先删除pod2、再删除对应的deployment否则只是删除pod是不管用的,还会看到pod,因为deployment.yaml文件中定义了副本数量


实例如下:

删除pod

[root@test2 ~]# kubectl get pod -n jenkins
NAME READY STATUS RESTARTS AGE
jenkins2-8698b5449c-grbdm 1/1 Running 0 8s
[root@test2 ~]# kubectl delete pod jenkins2-8698b5449c-grbdm -n jenkins
pod "jenkins2-8698b5449c-grbdm" deleted

查看pod仍然存储

[root@test2 ~]# kubectl get pod -n jenkins
NAME READY STATUS RESTARTS AGE
jenkins2-8698b5449c-dbqqb 1/1 Running 0 8s
[root@test2 ~]#

删除deployment

[root@test2 ~]# kubectl get deployment -n jenkins
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
jenkins2 1 1 1 1 17h
[root@test2 ~]# kubectl delete deployment jenkins2 -n jenkins

再次查看pod消失

deployment.extensions "jenkins2" deleted
[root@test2 ~]# kubectl get deployment -n jenkins
No resources found.
[root@test2 ~]#
[root@test2 ~]# kubectl get pod -n jenkins
No resources found.

 

k8s - 解决Terminating状态的Pod删不掉的问题(强行kubectl delete pod)

1,问题描述

(1)最近发现咋 Kubernetes 集群上有个处于 Terminating 状态的 Pod:
k8s中正确删除一个pod
(2)但通过 kubectl delete pods 命令却死活无法将其删除:
kubectl delete pods httpd-app-6df58645c6-cxgcm

 

2,解决办法

(1)无论各种方式生成的 pod, 均可以使用如下命令强制删除:
kubectl delete pods <pod> --grace-period=0 --force


(2)因此对于上面的 pod,我们只要执行如下命令即可删除:

kubectl delete pods httpd-app-6df58645c6-cxgcm --grace-period=0 --force

k8s中正确删除一个pod

上一篇:coderwhy-vue-课件


下一篇:一张图让你理清渗透思路