title | weight | catalog | date | subtitle | header-img | tags | catagories | ||
---|---|---|---|---|---|---|---|---|---|
金丝雀发布 |
1 |
true |
2023-05-31 03:50:57 -0700 |
|
|
金丝雀发布是指控制更新过程中的滚动节奏,通过“暂停”(pause)或“继续”(resume)更新发布操作。通过一小部分的版本发布实例来观察新版本是否有异常,如果没有异常则依次发布剩余的实例。
主要是两个字段的设置:
- maxSurge:最大发版实例数,可以创建的超出期望 Pod 个数的 Pod 数量。可以是百分比或者是数字。
- maxUnavailable:最大不可用实例数。可以是百分比或数字。
# 例如将maxSurge设置为1,maxUnavailable设置为0
$ kubectl patch deployment myapp-deploy -p '{"spec": {"strategy": {"rollingUpdate": {"maxSurge": 1, "maxUnavailable": 0}}}}'
kubectl set image deployment myapp-deploy myapp=kubernetes/myapp:v3 && \
kubectl rollout pause deployments myapp-deploy
$ kubectl rollout status deployment myapp-deploy
Waiting for deployment "myapp-deploy" rollout to finish: 1 out of 3 new replicas have been updated...
观察灰度的实例的流量是否正常,如果正常则继续发版,如果不正常则回滚之前的升级。
$ kubectl rollout resume deployments myapp-deploy
kubectl rollout undo deployments myapp-deploy
$ kubectl rollout history deployment myapp-deploy
deployment.apps/myapp-deploy
REVISION CHANGE-CAUSE
3 <none>
5 <none>
6 <none>
kubectl rollout undo deployment myapp-deploy --to-revision 3
参考: