在以前咱們建立了一個部署,而後經過服務公開它。部署只建立了一個Pod來運行咱們的應用程序。當流量增長時,咱們須要擴展應用程序以知足用戶需求。bash
經過更改部署中的副本數來完成擴展。mvc
這裏將拓展副本到4個負載均衡
[root@master ~]# kubectl scale deployments/kubernetes-bootcamp --replicas=4 deployment.extensions/kubernetes-bootcamp scaled [root@master ~]# kubectl get deployment NAME READY UP-TO-DATE AVAILABLE AGE kubernetes-bootcamp 4/4 4 4 5h11m
[root@master ~]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES kubernetes-bootcamp-7f56b875dc-6zbjt 1/1 Running 0 5h12m 10.244.0.15 master <none> <none> kubernetes-bootcamp-7f56b875dc-cp7cq 1/1 Running 0 47s 10.244.0.16 master <none> <none> kubernetes-bootcamp-7f56b875dc-n4wkn 1/1 Running 0 47s 10.244.0.17 master <none> <none> kubernetes-bootcamp-7f56b875dc-pmvck 1/1 Running 0 47s 10.244.0.18 master <none> <none>
[root@master ~]# kubectl describe deployments/kubernetes-bootcamp Name: kubernetes-bootcamp ..... ..... Type Status Reason ---- ------ ------ Progressing True NewReplicaSetAvailable Available True MinimumReplicasAvailable OldReplicaSets: <none> NewReplicaSet: kubernetes-bootcamp-7f56b875dc (4/4 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 4m28s deployment-controller Scaled up replica set kubernetes-bootcamp-7f56b875dc to 4
[root@master ~]# curl http://192.168.0.10:31238 Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-7f56b875dc-6zbjt | v=1 [root@master ~]# curl http://192.168.0.10:31238 Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-7f56b875dc-cp7cq | v=1 [root@master ~]# curl http://192.168.0.10:31238 Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-7f56b875dc-pmvck | v=1 [root@master ~]# curl http://192.168.0.10:31238 Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-7f56b875dc-n4wkn | v=1 [root@master ~]#