k8s mysql 弹性_k8s日常使用命令scale弹性伸缩pod
1.目前是三个pod[[emailprotected] service_pod]# kubectl get podNAME? ? ? ? ? ? ? ? ? ?? READY? ?? STATUS? ? RESTARTS?? AGEmysql-5bbbf49b4f-p7zkz?? 1/1? ? ?? Running?? 0? ? ? ? ? 2mmysql-5bbbf49b4f-vhj44?? .
1.
目前是三个pod
[[email protected] 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
[[email protected] 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
测试下参考命令
[[email protected] service_pod]# kubectl get deployment
NAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGE
mysql? ?? 3? ? ? ?? 3? ? ? ?? 3? ? ? ? ? ? 3? ? ? ? ?? 9m
[[email protected] service_pod]# kubectl scale --current-replicas=3 --replicas=1 deployment/mysql
deployment.extensions "mysql" scaled
[[email protected] service_pod]# kubectl get deployment
NAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGE
mysql? ?? 1? ? ? ?? 1? ? ? ?? 1? ? ? ? ? ? 1? ? ? ? ?? 10m
3.
增加pod
测试下命令
[[email protected] service_pod]# kubectl get deployment
NAME? ? ? DESIRED?? CURRENT?? UP-TO-DATE?? AVAILABLE?? AGE
mysql? ?? 1? ? ? ?? 1? ? ? ?? 1? ? ? ? ? ? 1? ? ? ? ?? 13m
[[email protected] service_pod]# kubectl scale --current-replicas=1 --replicas=3 deployment/mysql
deployment.extensions "mysql" scaled
[[email protected] 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
[[email protected] service_pod]#
更多推荐
所有评论(0)