Kubernates之Deployment滚动升级和回滚

编程

    k8s版本1.14

查看Deployment的升级历史

    List-1

xx@xx:~/xx$ kubectl rollout history deployment xxxx -n xxx

deployment.extensions/xxx

REVISION CHANGE-CAUSE

6 <none>

7 <none>

8 <none>

    从上面的结果可以看出在执行Deployment升级的时候最好带上record参数,便于查看历史版本信息

查看单个revison的信息

    List-2

xx@xx:~/xx$ kubectl rollout history deployment xxxx --revision=8  -n xxx

deployment.extensions/xxx with revision #8

Pod Template:

Labels: app=xx

pod-template-hash=65d95b7bd7

Annotations: cattle.io/timestamp: 2020-07-30T03:31:16Z

field.cattle.io/ports: [[{"containerPort":8180,"dnsName":"xx-","name":"port","protocol":"TCP","sourcePort":0}]]

Containers:

unstruct:

Image: xxxxx/apps/jdk8:5

Port: 8180/TCP

Host Port: 0/TCP

Command:

/bin/bash

/tmp/config/start.sh

-d

Environment:

.......略

Mounts:

/tmp/config from config (rw)

Volumes:

config:

Type: ConfigMap (a volume populated by a ConfigMap)

Name: cm-xxxx

Optional: false

回滚之前的rs信息

    List-3

xxx@xxx:~/xxx$ kubectl get rs -n xxx

NAME DESIRED CURRENT READY AGE

xx-54dffb5d47 1 1 1 39h

xx-58bc66466 0 0 0 7d13h

xx-66dd79b8bb 0 0 0 7d22h

xxx-65d95b7bd7 1 1 1 22h

xxx-68c5bb8cb 0 0 0 23h

xxx-787c4c9c59 0 0 0 39h

    回滚之前rs的版本是xxx-65d95b7bd7

回滚到版本7

    我们指定版本进行回滚,如果没有指定revision,那么是回滚到上一个版本

    List-4

xx@xxx:~/xxx$ kubectl rollout undo deployment xxx --to-revision=7  -n xxx

deployment.extensions/xxx rolled back

查看rs信息

    List-5

xx@xx:~/xxx$ kubectl get rs -n xxx

NAME DESIRED CURRENT READY AGE

xx-54dffb5d47 1 1 1 39h

xx-58bc66466 0 0 0 7d13h

xx-66dd79b8bb 0 0 0 7d22h

xxx-65d95b7bd7 0 0 0 22h

xxx-68c5bb8cb 1 1 1 23h

xxx-787c4c9c59 0 0 0 39h

 

以上是 Kubernates之Deployment滚动升级和回滚 的全部内容, 来源链接: utcz.com/z/518916.html

回到顶部