https://kubernetes.io/zh/docs/concepts/workloads/controllers/deployment/
Strategy
.spec.strategy specifies the strategy used to replace old Pods by new ones.
.spec.strategy.type can be “Recreate” or “RollingUpdate”. “RollingUpdate” is the default value.
Recreate Deployment
All existing Pods are killed before new ones are created when .spec.strategy.type==Recreate.
Rolling Update Deployment
The Deployment updates Pods in a rolling update fashion when .spec.strategy.type==RollingUpdate.
You can specify maxUnavailable and maxSurge to control the rolling update process.
Max Unavailable
.spec.strategy.rollingUpdate.maxUnavailable is an optional field that specifies
the maximum number of Pods that can be unavailable during the update process.
The value can be an absolute number (for example, 5) or a percentage of desired Pods
(for example, 10%). The absolute number is calculated from percentage by rounding down.
The value cannot be 0 if .spec.strategy.rollingUpdate.maxSurge is 0. The default value is 25%.
For example, when this value is set to 30%, the old ReplicaSet can be scaled down to 70% of
desired Pods immediately when the rolling update starts. Once new Pods are ready,
old ReplicaSet can be scaled down further, followed by scaling up the new ReplicaSet,
ensuring that the total number of Pods available at all times during the update is
at least 70% of the desired Pods.
Max Surge
.spec.strategy.rollingUpdate.maxSurge is an optional field that specifies the maximum number
of Pods that can be created over the desired number of Pods. The value can be an absolute
number (for example, 5) or a percentage of desired Pods (for example, 10%). The value cannot
be 0 if MaxUnavailable is 0. The absolute number is calculated from the percentage by rounding up.
The default value is 25%.
For example, when this value is set to 30%, the new ReplicaSet can be scaled up immediately
when the rolling update starts, such that the total number of old and new Pods does not exceed
130% of desired Pods. Once old Pods have been killed, the new ReplicaSet can be scaled up further,
ensuring that the total number of Pods running at any time during the update is at most 130%
of desired Pods.
maxSurge:滚动更新时最多可以多启动多少个pod
maxUnavailable:滚动更新时最大可以删除多少个pod
maxSurge和maxUnavailable可以用来决定更新是的最大pod数和最小pod数
是先启动一个pod再删除一个pod还是先删除一个pod再启动一个pod
例如
replicas是5
maxSurge: 1
maxUnavailable: 0
更新时 最大的pod数是 replicas+ maxSurge = 5+1 =6,最大的个数是6
最小pod数是 replicas - maxUnavailable = 5-0 = 5,最小pod数是5,所以只能先启动一个pod,再删除一个pod
https://blog.csdn.net/huiyanshizhen21/article/details/103146788