k8s中正确删除一个pod

Posted effortsing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s中正确删除一个pod相关的知识,希望对你有一定的参考价值。

1、先删除pod

2、再删除对应的deployment

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


实例如下:

删除pod

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

查看pod仍然存储

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

删除deployment

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

再次查看pod消失

deployment.extensions "jenkins2" deleted
[[email protected] ~]# kubectl get deployment -n jenkins
No resources found.
[[email protected] ~]# 
[[email protected] ~]# kubectl get pod -n jenkins
No resources found.

 

以上是关于k8s中正确删除一个pod的主要内容,如果未能解决你的问题,请参考以下文章

正确删除k8s版本jenkins

k8s删除pod一直处于terminating状态

k8s中pod删不掉

k8s中删除pod后仍然存在问题

怒喷k8s:竟然还要这么才能正确找到statefulset的pods

k8s删除pod一直terminating