[TOC]
Kubernetes deployment的scale out, scale down
扩容
kubectl scale deployments/<name> --replicas=4
查看扩容结果:
kubectl get deployments <name>
$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
kubernetes-bootcamp-5c69669756-rgzzp 1/1 Running 0 9m 172.18.0.5 minikube
kubernetes-bootcamp-5c69669756-zw7x6 1/1 Running 0 11m 172.18.0.2 minikube
缩容
kubectl scale deployments/kubernetes-bootcamp --replicas=2
将kubernetes-bootcamp
缩容到两个副本;
查看缩容结果:
$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
kubernetes-bootcamp-5c69669756-p6969 1/1 Terminating 0 9m 172.18.0.7 minikube
kubernetes-bootcamp-5c69669756-rgzzp 1/1 Running 0 9m 172.18.0.5 minikube
kubernetes-bootcamp-5c69669756-t6rrt 1/1 Terminating 0 9m 172.18.0.6 minikube
kubernetes-bootcamp-5c69669756-zw7x6 1/1 Running 0 11m 172.18.0.2 minikube
$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
kubernetes-bootcamp-5c69669756-rgzzp 1/1 Running 0 9m 172.18.0.5 minikube
kubernetes-bootcamp-5c69669756-zw7x6 1/1 Running 0 11m 172.18.0.2 minikube
Rolling Update
通过指定新的镜像对deployment进行升级:
kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatatlin/kubernetes-bootcamp:v2
kubectl set image <deployment name> <deployment name>=<new image path and name>
rollout管理:
- rollout状态查看:
kubectl rollout status deployments/<deployment name>
- rollout撤销:
kuberctl rollout undo deployments/<deployment name>
网友评论