|NO.Z.00143|——————————|CloudNative|——|KuberNetes&資源排程.V13|-------------------------------------------------------|statefulset.v05|更新.V02|OnDelete|
阿新 • • 發佈:2022-03-30
[CloudNative:KuberNetes&資源排程.V13] [Applications.KuberNetes] [StatefulSet應用|容器中匯出映象匯入映象StatefulSet擴容縮容StatefulSet建立pod縮減pod的流程|] [StatefulSet更新策略|StatefulSet灰度釋出|StatefulSet級聯刪除和非級聯刪除|]
三、StatefulSet更新策略二:OnDelete
### --- 新增配置引數,觸發更新 ~~~ # 更改StatefulSet配置引數映象版本更改為1.15.3 ~~~ 使用 OnDelete去更新;它是不會觸發更新的,只有把這個Pod刪除之後才會觸發更新映象 [root@k8s-master01 ~]# kubectl edit sts web spec: containers: - image: nginx:1.15.3 updateStrategy: type: OnDelete
~~~ # 檢視pod的狀態
[root@k8s-master01 ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
web-0 1/1 Running 0 7m21s
web-1 1/1 Running 0 7m18s
web-2 1/1 Running 0 8m1s
### --- 刪除web-2觸發更新 ~~~ # 刪除web-2;觸發更新 [root@k8s-master01 ~]# kubectl delete po web-2 pod "web-2" deleted
~~~ # 檢視已更新web-2.pod的映象版本 [root@k8s-master01 ~]# kubectl get po web-2 -oyaml |grep image f:image: {} f:imagePullPolicy: {} - image: nginx:1.15.3 // 可以檢視到它的映象版本是1.15.3 imagePullPolicy: IfNotPresent image: nginx:1.15.3 imageID: docker-pullable://nginx@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
~~~ # 檢視未更新web-1.pod的映象版本
[root@k8s-master01 ~]# kubectl get po web-1 -oyaml |grep image
f:image: {}
f:imagePullPolicy: {}
- image: nginx:1.15.2 // 而是web-1的映象是1.15.2,沒有更新
imagePullPolicy: IfNotPresent
image: nginx:1.15.2
imageID: docker-pullable://nginx@sha256:d85914d547a6c92faa39ce7058bd7529baacab7e0cd4255442b04577c4d1f424
### --- 檢視statefuel.OnDelete更新流程
~~~ # 檢視pod的更新流程
[root@k8s-master01 ~]# kubectl get po -l app=nginx -w
web-2 1/1 Terminating 0 8m59s //刪除web-2之後觸發更新
web-2 0/1 Terminating 0 9m1s
web-2 0/1 Terminating 0 10m
web-2 0/1 Terminating 0 10m
web-2 0/1 Pending 0 0s
web-2 0/1 Pending 0 0s
web-2 0/1 ContainerCreating 0 1s
web-2 1/1 Running 0 3s
~~~ # 那麼我們同時刪除web-0和web-1,讓他觸發更新
[root@k8s-master01 ~]# kubectl delete po web-0 web-1
pod "web-0" deleted
pod "web-1" deleted
~~~ # 檢視對應的映象版本
[root@k8s-master01 ~]# kubectl get po -oyaml |grep image //可以看到所有的映象版本都更新為1.15.3
f:image: {}
f:imagePullPolicy: {}
- image: nginx:1.15.3
imagePullPolicy: IfNotPresent
image: nginx:1.15.3
imageID: docker-pullable://nginx@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
f:image: {}
f:imagePullPolicy: {}
- image: nginx:1.15.3
imagePullPolicy: IfNotPresent
image: nginx:1.15.3
imageID: docker-pullable://nginx@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
f:image: {}
f:imagePullPolicy: {}
- image: nginx:1.15.3
imagePullPolicy: IfNotPresent
image: nginx:1.15.3
imageID: docker-pullable://nginx@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
### --- 檢視pod的更新流程
[root@k8s-master01 ~]# kubectl get po -l app=nginx -w
web-0 1/1 Terminating 0 12m
web-1 1/1 Terminating 0 12m
web-0 0/1 Terminating 0 12m
web-1 0/1 Terminating 0 12m
web-0 0/1 Terminating 0 13m
web-0 0/1 Pending 0 1s
web-0 0/1 ContainerCreating 0 1s
web-0 1/1 Running 0 3s
web-1 0/1 Pending 0 0s
web-1 0/1 ContainerCreating 0 0s
web-1 1/1 Running 0 2s
===============================END===============================
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
來自為知筆記(Wiz)