1.查看镜像
[root@k8s-master01 ~]# kubectl get deploy -oyaml |grep image
f:image: {}
f:imagePullPolicy: {}
- image: nginx:1.15.2
imagePullPolicy: IfNotPresent
2.更改镜像
[root@k8s-master01 ~]# kubectl set image delploy nginx nginx=nginx:1.15.3 --record ### --record:记录
3.查看状态
[root@k8s-master01 ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
nginx-5dfc8689c6-gjnps 0/1 ContainerCreating 0 6s
nginx-66bbc9fdc5-jmgwq 1/1 Running 0 40m
nginx-66bbc9fdc5-rjqpk 1/1 Running 0 15m
# 查看进度
[root@k8s-master01 ~]# kubectl rollout status deploy nginx
Waiting for deployment "nginx" rollout to finish: 1 out of 2 new replicas have been updated...
Waiting for deployment "nginx" rollout to finish: 1 out of 2 new replicas have been updated...
Waiting for deployment "nginx" rollout to finish: 1 out of 2 new replicas have been updated...
Waiting for deployment "nginx" rollout to finish: 1 old replicas are pending termination...
Waiting for deployment "nginx" rollout to finish: 1 old replicas are pending termination...
deployment "nginx" successfully rolled out
# 查看流程
[root@k8s-master01 ~]# kubectl describe deploy nginx
# 查看RS
[root@k8s-master01 ~]# kubectl get po --show-labels
NAME READY STATUS RESTARTS AGE LABELS
nginx-6cdd5dd489-njqjd 1/1 Running 0 10m app=nginx,pod-template-hash=6cdd5dd489
nginx-6cdd5dd489-pb8qk 1/1 Running 0 10m app=nginx,pod-template-hash=6cdd5dd489
# 查看状态
[root@k8s-master01 ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
nginx-5dfc8689c6-cw87q 1/1 Running 0 60s
nginx-5dfc8689c6-gjnps 1/1 Running 0 2m4s
nginx-66bbc9fdc5-jmgwq 0/1 Terminating 0 42m # 我们的副本是2,滚动更新会先1一个running后,会删除一个pod,在起一个。
查看镜像
[root@k8s-master01 ~]# kubectl get po nginx-5dfc8689c6-cw87q -oyaml|grep image
f:image: {}
f:imagePullPolicy: {}
- image: nginx:1.15.3
imagePullPolicy: IfNotPresent
image: nginx:1.15.3
imageID: docker-pullable://nginx@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3