k8s中删除pod的操作

 

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.

 

上一篇:第1章 网络编程基础(2)——Socket编程原理


下一篇:k8s部署 apiVersion升级问题