Applying a rolling update strategy
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
rollingUpdate:
maxSurge: 1
maxUnavailable: 99%
- maxSurge
- The
maxSurgeparameter defines how many extra pods can be added to the set number ofreplicasduring an update. ThemaxSurgeparameter allows Red Hat OpenShift to create new pods before it deletes old ones to maximize availability. The value can be a number or a percentage. For example, ifmaxSurgeis 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. - maxUnavailable
- The
maxUnavailableparameter defines the maximum number of old pods that are allowed to be down during an update. By default, OpenShift removes 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 ofmaxUnavailableis 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), maxSurge is set to 1, and maxUnavailable is set to
25%.