1.
目前是三个 pod
- [root@k8s-master1 service_pod]# kubectl get pod
- NAME? ? ? ? ? ? ? ? ? ?? READY? ?? STATUS? ? RESTARTS?? AGE
- MySQL-5bbbf49b4f-p7zkz?? 1/1? ? ?? Running?? 0? ? ? ? ? 2m
- MySQL-5bbbf49b4f-vhj44?? 1/1? ? ?? Running?? 1? ? ? ? ? 2m
- MySQL-5bbbf49b4f-xzpwn?? 1/1? ? ?? Running?? 1? ? ? ? ? 2m
- [root@k8s-master1 service_pod]#
想扩大到 5 个 pod
官方参考命令格式, 见下:
- Examples:
- ? # Scale a replicaset named 'foo' to 3.
- ? kubectl scale --replicas=3 rs/foo
- ? # Scale a resource identified by type and name specified in "foo.yaml" to 3.
- ? kubectl scale --replicas=3 -f foo.YAML
- ? # If the deployment named MySQL's current size is 2, scale MySQL to 3.
- ? kubectl scale --current-replicas=2 --replicas=3 deployment/MySQL
- ? # Scale multiple replication controllers.
- ? kubectl scale --replicas=5 rc/foo rc/bar rc/baz
- ? # Scale statefulset named 'web' to 3.
- ? kubectl scale --replicas=3 statefulset/Web
- 2.
减少 pod
测试下参考命令
- [root@k8s-master1 service_pod]# kubectl get deployment
- NAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGE
- MySQL? ?? 3? ? ? ?? 3? ? ? ?? 3? ? ? ? ? ? 3? ? ? ? ?? 9m
- [root@k8s-master1 service_pod]# kubectl scale --current-replicas=3 --replicas=1 deployment/MySQL
- deployment.extensions "mysql" scaled
- [root@k8s-master1 service_pod]# kubectl get deployment
- NAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGE
- MySQL? ?? 1? ? ? ?? 1? ? ? ?? 1? ? ? ? ? ? 1? ? ? ? ?? 10m
- 3.
增加 pod
测试下命令
- [root@k8s-master1 service_pod]# kubectl get deployment
- NAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGE
- MySQL? ?? 1? ? ? ?? 1? ? ? ?? 1? ? ? ? ? ? 1? ? ? ? ?? 13m
- [root@k8s-master1 service_pod]# kubectl scale --current-replicas=1 --replicas=3 deployment/MySQL
- deployment.extensions "mysql" scaled
- [root@k8s-master1 service_pod]# kubectl get pod
- NAME? ? ? ? ? ? ? ? ? ?? READY? ?? STATUS? ? RESTARTS?? AGE
- MySQL-5bbbf49b4f-96v7g?? 1/1? ? ?? Running?? 0? ? ? ? ? 5s
- MySQL-5bbbf49b4f-f6rlg?? 1/1? ? ?? Running?? 0? ? ? ? ? 5s
- MySQL-5bbbf49b4f-p7zkz?? 1/1? ? ?? Running?? 0? ? ? ? ? 13m
- [root@k8s-master1 service_pod]#
来源: http://www.bubuko.com/infodetail-2820984.html