Deployment回滚

1.查看当前镜像

[root@k8s-master01 ~]# kubectl get deploy nginx -oyaml|grep image
    kubernetes.io/change-cause: kubectl set image deploy nginx nginx=nginx:1.15.3
                f:imagePullPolicy: {}
                f:image: {}
      - image: nginx:1.15.2
        imagePullPolicy: IfNotPresent

2.查看更新历史

[root@k8s-master01 ~]# kubectl rollout history deploy nginx
deployment.apps/nginx 
REVISION  CHANGE-CAUSE
8         kubectl set image deploy nginx nginx=nginx:1.15.2 --record=true
9         kubectl set image deploy nginx nginx=nginx:1.15.4 --record=true
10        kubectl set image deploy nginx nginx=nginx:1.15.3 --record=true
11        kubectl set image deploy nginx nginx=nginx:1.15.3 --record=true
15        kubectl set image deploy nginx nginx=1.15.4 --record=true
16        kubectl set image deploy nginx nginx=nginx:1.15.3 --record=true

3.查看具体某个信息

[root@k8s-master01 ~]# kubectl rollout  history deploy nginx --revision=16 
deployment.apps/nginx with revision #16
Pod Template:
  Labels:	app=nginx
	pod-template-hash=65965557f7
  Annotations:	kubernetes.io/change-cause: kubectl set image deploy nginx nginx=nginx:1.15.3 --record=true
  Containers:
   nginx:
    Image:	nginx:1.15.2
    Port:	<none>
    Host Port:	<none>
    Limits:
      cpu:	200m
      memory:	128Mi
    Requests:
      cpu:	10m
      memory:	16Mi
    Environment:	<none>
    Mounts:	<none>
  Volumes:	<none>

4.回滚到上个版本

[root@k8s-master01 ~]# kubectl rollout  undo deploy nginx 
deployment.apps/nginx rolled back

5.回到指定版本

[root@k8s-master01 ~]# kubectl rollout undo deploy nginx --to-revision=9
[root@k8s-master01 ~]# kubectl get pod
NAME                     READY   STATUS    RESTARTS   AGE
nginx-6cdd5dd489-bs5wz   1/1     Running   0          59s
nginx-6cdd5dd489-n8xv9   1/1     Running   0          92s
[root@k8s-master01 ~]# kubectl get deploy nginx  -oyaml|grep image
    kubernetes.io/change-cause: kubectl set image deploy nginx nginx=nginx:1.15.4
                f:imagePullPolicy: {}
                f:image: {}
      - image: nginx:1.15.4
        imagePullPolicy: IfNotPresent
原文地址:https://www.cnblogs.com/Applogize/p/14383523.html