Applying a rolling update strategy
25.0.1.0
A rolling update gradually replaces the old pods of a deployment with new ones,
which keeps as many pods alive as possible to avoid downtime. A rolling update is triggered when any
change is made to an application, including the container image, environment variables, ports,
config, or any change to the custom resource.
About this task
A rolling update strategy uses two parameters:
spec:
strategy:
type: RollingUpdate
rolling_update:
max_surge: "1"
max_unavailable: "99%"
- max_surge
- The
max_surgeparameter defines how many extra pods can be added to the set number ofreplicasduring an update. Themax_surgeparameter allows Kubernetes clusters to create new pods before it deletes old ones to maximize availability. The value can be a number or a percentage. For example, ifmax_surgeis set to 1, then up to 1 extra pod can be created temporarily during a rolling update. If the value of thereplicasparameter is set to 2, then the maximum number of pods is 3. - max_unavailable
- The
max_unavailableparameter defines the maximum number of old pods that are allowed to be down during an update. By default, Kubernetes clusters remove one pod at a time as it creates new pods, which makes sure that the setreplicascount is maintained. The value can be a number or a percentage. For example, if the value ofmax_unavailableis set to 99% and the number ofreplicasis set to 2, then 99% of 2 is 1.98. The value 1.98 is rounded down to 1, so 1 pod can be taken offline during the update.
The following steps explain how a rolling update strategy works. For the example, the
replicas parameter is set to 5 (the 5 running pods are named A, B, C, D,
E), max_surge is set to 1, and max_unavailable is set to
25%.