03-k8s部署应用,扩缩容

创建一个为demoapp的POD,应用镜像为nginx,副本数为3
[root@master ~]# kubectl create deployment demoapp --image=nginx --replicas=3
deployment.apps/demoapp created


扩展POD的副本数从原来的副本数3,扩展到5

先来查看默认的副本数,这里可以看到demoapp的副本的数量是3个
[root@master ~]#  kubectl get pod
NAME                       READY   STATUS    RESTARTS   AGE
demoapp-79b7d5f68b-2dw6g   1/1     Running   0          2m57s
demoapp-79b7d5f68b-b2rw5   1/1     Running   0          2m57s
demoapp-79b7d5f68b-x4jvx   1/1     Running   0          2m57s
nginx-6799fc88d8-47rfc     1/1     Running   0          82m
nginx-6799fc88d8-kcms7     1/1     Running   0          82m
nginx-6799fc88d8-tp7ff     1/1     Running   0          82m

扩展demoapp的副本数为5个
[root@master ~]# kubectl scale deployment demoapp --replicas=5
deployment.apps/demoapp scaled

查看副本数,是否扩展成功,这里可以看到demoapp的副本数已经为5个了
[root@master ~]#  kubectl get pod
NAME                       READY   STATUS              RESTARTS   AGE
demoapp-79b7d5f68b-2dw6g   1/1     Running             0          7m18s
demoapp-79b7d5f68b-85vrb   1/1     ContainerCreating   0          3s
demoapp-79b7d5f68b-b2rw5   1/1     Running             0          7m18s
demoapp-79b7d5f68b-rj4wn   1/1     ContainerCreating   0          3s
demoapp-79b7d5f68b-x4jvx   1/1     Running             0          7m18s
nginx-6799fc88d8-47rfc     1/1     Running             0          86m
nginx-6799fc88d8-kcms7     1/1     Running             0          86m
nginx-6799fc88d8-tp7ff     1/1     Running             0          86m


吧demoapp的副本数缩容到3个
[root@master ~]# kubectl scale deployment demoapp --replicas=3
deployment.apps/demoapp scaled

查看demoapp的副本数量
[root@master ~]# kubectl get pod
NAME                       READY   STATUS    RESTARTS   AGE
demoapp-79b7d5f68b-2dw6g   1/1     Running   0          79m
demoapp-79b7d5f68b-b2rw5   1/1     Running   0          79m
demoapp-79b7d5f68b-x4jvx   1/1     Running   0          79m
nginx-6799fc88d8-47rfc     1/1     Running   0          158m
nginx-6799fc88d8-kcms7     1/1     Running   0          158m
nginx-6799fc88d8-tp7ff     1/1     Running   0          158m


Powered By Z-BlogPHP 1.7.3

 Theme By 优美模版

本博客为开源博客,本博客联系QQ:372097243