1.
Three pods
[[email protected] service_pod]# kubectl get podNAME? ? ? ? ? ? ? ? ? ?? READY? ?? STATUS? ? RESTARTS?? AGEmysql-5bbbf49b4f-p7zkz?? 1/1? ? ?? Running?? 0? ? ? ? ? 2mmysql-5bbbf49b4f-vhj44?? 1/1? ? ?? Running?? 1? ? ? ? ? 2mmysql-5bbbf49b4f-xzpwn?? 1/1? ? ?? Running?? 1? ? ? ? ? 2m[[email protected] service_pod]#
Expand to 5 pods
For official reference to the Command Format, see:
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.
Reduce pod
Test the command
[[email protected] service_pod]# kubectl get deploymentNAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGEmysql? ?? 3? ? ? ?? 3? ? ? ?? 3? ? ? ? ? ? 3? ? ? ? ?? 9m[[email protected] service_pod]# kubectl scale --current-replicas=3 --replicas=1 deployment/mysqldeployment.extensions "mysql" scaled[[email protected] service_pod]# kubectl get deploymentNAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGEmysql? ?? 1? ? ? ?? 1? ? ? ?? 1? ? ? ? ? ? 1? ? ? ? ?? 10m
3.
Add pod
Test command
[[email protected] service_pod]# kubectl get deploymentNAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGEmysql? ?? 1? ? ? ?? 1? ? ? ?? 1? ? ? ? ? ? 1? ? ? ? ?? 13m[[email protected] service_pod]# kubectl scale --current-replicas=1 --replicas=3 deployment/mysqldeployment.extensions "mysql" scaled[[email protected] service_pod]# kubectl get podNAME? ? ? ? ? ? ? ? ? ?? READY? ?? STATUS? ? RESTARTS?? AGEmysql-5bbbf49b4f-96v7g?? 1/1? ? ?? Running?? 0? ? ? ? ? 5smysql-5bbbf49b4f-f6rlg?? 1/1? ? ?? Running?? 0? ? ? ? ? 5smysql-5bbbf49b4f-p7zkz?? 1/1? ? ?? Running?? 0? ? ? ? ? 13m[[email protected] service_pod]#
K8s daily command scale auto scaling pod