Middle+
How does Kubernetes update a Deployment when applying a new configuration (rolling update)?
sobes.tech AI
Answer from AI
Kubernetes uses a rolling update strategy when updating a Deployment, which allows gradually replacing old Pods with new ones without downtime.
Main steps:
- A new ReplicaSet is created with the updated configuration.
- The number of Pods in the old ReplicaSet is gradually decreased, and in the new one increased, usually by one or according to the parameters maxUnavailable and maxSurge.
- Kubernetes monitors the state of the new Pods, waits for their readiness, before deleting the old ones.
- If the new Pods do not become Ready, the update is paused (rollback is possible).
Example deployment parameters for managing updates:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
Thus, the update occurs smoothly, without service interruption, with control over availability and rollback capability.