k8s版本1.14
查看Deployment的升级历史
List-1
1xx@xx:~/xx$ kubectl rollout history deployment xxxx -n xxx 2deployment.extensions/xxx 3REVISION CHANGE-CAUSE 46 <none> 57 <none> 68 <none>
从上面的结果可以看出在执行Deployment升级的时候最好带上record参数,便于查看历史版本信息
查看单个revison的信息
List-2
1xx@xx:~/xx$ kubectl rollout history deployment xxxx --revision=8 -n xxx 2deployment.extensions/xxx with revision #8 3Pod Template: 4 Labels: app=xx 5 pod-template-hash=65d95b7bd7 6 Annotations: cattle.io/timestamp: 2020-07-30T03:31:16Z 7 field.cattle.io/ports: [[{"containerPort":8180,"dnsName":"xx-","name":"port","protocol":"TCP","sourcePort":0}]] 8 Containers: 9 unstruct: 10 Image: xxxxx/apps/jdk8:5 11 Port: 8180/TCP 12 Host Port: 0/TCP 13 Command: 14 /bin/bash 15 /tmp/config/start.sh 16 -d 17 Environment: 18 .......略 19 Mounts: 20 /tmp/config from config (rw) 21 Volumes: 22 config: 23 Type: ConfigMap (a volume populated by a ConfigMap) 24 Name: cm-xxxx 25 Optional: false 26
回滚之前的rs信息
List-3
1xxx@xxx:~/xxx$ kubectl get rs -n xxx 2NAME DESIRED CURRENT READY AGE 3xx-54dffb5d47 1 1 1 39h 4xx-58bc66466 0 0 0 7d13h 5xx-66dd79b8bb 0 0 0 7d22h 6xxx-65d95b7bd7 1 1 1 22h 7xxx-68c5bb8cb 0 0 0 23h 8xxx-787c4c9c59 0 0 0 39h
回滚之前rs的版本是xxx-65d95b7bd7
回滚到版本7
我们指定版本进行回滚,如果没有指定revision,那么是回滚到上一个版本
List-4
1xx@xxx:~/xxx$ kubectl rollout undo deployment xxx --to-revision=7 -n xxx 2deployment.extensions/xxx rolled back
查看rs信息
List-5
1xx@xx:~/xxx$ kubectl get rs -n xxx 2NAME DESIRED CURRENT READY AGE 3xx-54dffb5d47 1 1 1 39h 4xx-58bc66466 0 0 0 7d13h 5xx-66dd79b8bb 0 0 0 7d22h 6xxx-65d95b7bd7 0 0 0 22h 7xxx-68c5bb8cb 1 1 1 23h 8xxx-787c4c9c59 0 0 0 39h