首页 > 其他 > 详细

K8S kubectl 常用命令 - 升级回滚,弹性伸缩

时间:2021-02-28 00:05:00      阅读:41      评论:0      收藏:0      [点我收藏+]
# 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

 

K8S kubectl 常用命令 - 升级回滚,弹性伸缩

原文:https://www.cnblogs.com/Tifahfyf/p/14457378.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!