How does rolling update work in kubernetes internally. Is it one pod after another. will the update get stuck or takes time if one of the pod goes to error state during the update
There are two fields (maxSurge and maxUnavailable) on the deployment spec that you can use to control how a rolling update is performed. kubectl explain deployment.spec.strategy.rollingUpdate will give you full details about these fields, but in short they determine how many pods you can go over your replica count and how many pods can become unavailable respectively during a rolling update.
For the maxUnavailable field to work properly, it's important to configure readiness probes on your pod template properly.
More information can be found here.
From design document:
For the purposes of this example, assume that we are rolling from
footofoo-nextwhere the only change is an image update fromv1tov2If the user doesn't specify a
foo-next name, then it is either discovered from the update-partner annotation on foo. If that annotation doesn't exist, then foo-next is synthesized using the pattern<controller-name>-<hash-of-next-controller-JSON>Initialization
If
fooandfoo-nextdo not exist:
- Exit, and indicate an error to the user, that the specified controller doesn't exist.
If
fooexists, butfoo-nextdoes not:
- Create
foo-nextpopulate it with thev2image, setdesired-replicastofoo.Spec.ReplicasIf
foo-nextexists, butfoodoes not:
Assume that we are in the rename phase.
Goto Rename
If both
fooandfoo-nextexist:
Assume that we are in a partial rollout
If
foo-nextis missing thedesired-replicasannotation
- Populate the
desired-replicasannotation tofoo-nextusing the current size offooGoto Rollout
Rollout
While size of
foo-next<desired-replicasannotation onfoo-next
- increase size of
foo-next- if size of
foo> 0 decrease size offooGoto Rename
Rename
delete
foocreate
foothat is identical tofoo-nextdelete
foo-nextAbort
If
foo-nextdoesn't exist
- Exit and indicate to the user that they may want to simply do a new rollout with the old version
If
foodoesn't exist
- Exit and indicate not found to the user
Otherwise,
foo-nextandfooboth exist
Set
desired-replicas annotation onfooto match the annotation onfoo-nextGoto Rollout with
fooandfoo-nexttrading places.