k8s中删除pod的操作-杂谈-IT技术博客

k8s中删除pod的操作

时间:2021-04-28 17:14:00 浏览: 字体: 放大 缩小


 

1、先删除对应的deployment
2、再删除pod(此步骤可以省略)
否则只是删除pod是不管用的,还会看到pod,因为deployment.yaml文件中定义了副本数量

实例如下:

 

查看pods和deployment信息

[root@t194 ~]# kubectl get pods
NAME                        READY   STATUS    RESTARTS   AGE
my-nginx-5b555966b9-hgmcm   1/1     Running   0          22m
my-nginx-5b555966b9-rv9jk   1/1     Running   0          22m
[root@t194 ~]# kubectl get deployment 
NAME       READY   UP-TO-DATE   AVAILABLE   AGE
my-nginx   2/2     2            2           25m

删除deployment

[root@t194 ~]# kubectl delete deployment my-nginx 
deployment.extensions "my-nginx" deleted

查看pod状态,Running----Terminating---直到最后删除掉

[root@t194 ~]# kubectl get pod
NAME                        READY   STATUS        RESTARTS   AGE
my-nginx-5b555966b9-hgmcm   0/1     Terminating   0          26m
[root@t194 ~]# kubectl get pod
No resources found.

 

标签: k8s中删除pod的操作k8s删除pod操作