A Deployment describes the desired state of a stateless app. It then keeps the cluster in that state. The desired state includes:
- which image to run
- how many replicas (copies) to run
- the Pod template
The Deployment manages ReplicaSets. A ReplicaSet keeps the right number of Pods running and replaces any that die.
How a rolling update works:
- You change the Pod template, for example to a new image tag.
- The Deployment creates a new ReplicaSet.
- It slowly scales the new ReplicaSet up and the old one down.
Controlling the pace:
maxSurgesets how many extra Pods may exist during the update.maxUnavailablesets how many Pods may be missing.- Both are 25% by default.
New Pods get traffic only after their readiness probe passes. This is a check that the app is ready to serve. So a broken version stops the rollout instead of taking the service down.
kubectl rollout status follows the progress. kubectl rollout undo rolls back to the previous ReplicaSet.
- A Deployment declares the number of replicas and the Pod template.
- It manages ReplicaSets, which keep the Pods running.
- A rolling update moves Pods from the old ReplicaSet to the new one.
maxSurgeandmaxUnavailablecontrol the pace of the update.- Readiness probes decide when Pods get traffic, and
kubectl rollout undorolls back.
Read more