# yaml文件内容 apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: xxxxxxxxxxx name: xxxxxxxxxxx spec: replicas: 2 # 2 副本 selector: matchLabels: # controller匹配pod标签 app: xxxxxxxxxxx strategy: {} template: metadata: creationTimestamp: null labels: # 标签 app: xxxxxxxxxxx spec: containers: - image: nginx:1.14 # 1.14版本nginx name: nginx resources: {} status: {}
# 应用升级nginx到1.15
kubectl set image deployment xxxxxxxxxxx nginx=nginx:1.15
# 查看升级状态
kubectl rollout status deployment xxxxxxxxxxx
# 查看历史版本
kubectl rollout history deployment xxxxxxxxxxx
# 回滚,还原到上一个版本
kubectl rollout undo deployment xxxxxxxxxxx
# 回滚到指定版本
kubectl rollout undo deployment xxxxxxxxxxx --to-revision=2
# 2 表示版本?
# 弹性伸缩
kubectl scale deployment xxxxxxxxxxx --replicas=5
原文:https://www.cnblogs.com/Tifahfyf/p/14457378.html