- 华为云
- 升级Deployment:
$ kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1
$ kubectl set resources deployment/nginx-deployment -c=nginx —limits=cpu=200m,memory=512Mi - 升级策略:
minReadySeconds: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 #默认25%
maxUnavailable: 1 #默认25% - 恢复Deployment:
$ kubectl rollout resume deployment/nginx-deployment - 查询升级状态:
$ kubectl rollout status deployment/nginx-deployment - 查询升级历史:
$ kubectl rollout history deploy/nginx-deployment
$ kubectl rollout history deploy/nginx-deployment —revision=2 - 回滚:
$ kubectl rollout undo deployment/nginx-deployment —to-revision=2 - 对接了heapster,和HPA联动后:
$ kubectl autoscale deployment nginx-deployment —min=10 —max=15 —cpu-percent=80
华为云
现在这一套已经被淘汰了,prometheus+grafan主流
Deployment升级与回滚 - 1
# 创建Deployment:
$ kubectl run {deployment} –image={image} –replicas={rep.}
# 或使用yaml文件形式,重点配置replicas和image字段。
升级Deployment:
$ kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1
$ kubectl set resources deployment/nginx-deployment -c=nginx —limits=cpu=200m,memory=512Mi
升级策略:
minReadySeconds: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 #默认25%
maxUnavailable: 1 #默认25%
Deployment升级与回滚 - 2
# 暂停Deployment:
$ kubectl rollout pause deployment/nginx-deployment
恢复Deployment:
$ kubectl rollout resume deployment/nginx-deployment
查询升级状态:
$ kubectl rollout status deployment/nginx-deployment
查询升级历史:
$ kubectl rollout history deploy/nginx-deployment
$ kubectl rollout history deploy/nginx-deployment —revision=2
回滚:
$ kubectl rollout undo deployment/nginx-deployment —to-revision=2
应用弹性伸缩
$ kubectl scale deployment nginx-deployment —replicas=10