0
0
Kubernetesdevops~10 mins

Rolling update strategy in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Rolling update strategy
Start with current version pods
Create new version pods gradually
Wait for new pods to be ready
Delete old version pods gradually
Check if all pods are updated
Continue update
The rolling update replaces old pods with new ones step-by-step, ensuring availability by creating new pods before deleting old ones.
Execution Sample
Kubernetes
kubectl set image deployment/myapp myapp=nginx:2.0
# Rolling update starts
kubectl rollout status deployment/myapp
This command updates the image of the deployment 'myapp' to version 2.0 and monitors the rolling update progress.
Process Table
StepActionPods Old VersionPods New VersionStatusNotes
1Start rolling update30Old version runningAll pods running old version
2Create 1 new pod31New pod startingNew pod created, old pods still running
3Wait for new pod ready31New pod readyNew pod passed readiness checks
4Delete 1 old pod21Old pod terminatedOne old pod removed
5Create 1 new pod22New pod startingSecond new pod created
6Wait for new pod ready22New pod readySecond new pod ready
7Delete 1 old pod12Old pod terminatedAnother old pod removed
8Create 1 new pod13New pod startingThird new pod created
9Wait for new pod ready13New pod readyThird new pod ready
10Delete last old pod03Old pods terminatedAll old pods removed
11Update complete03All pods running new versionRolling update finished
💡 All old pods replaced by new pods, update complete
Status Tracker
VariableStartAfter Step 2After Step 4After Step 6After Step 8After Step 10Final
Pods Old Version3322100
Pods New Version0112333
StatusOld version runningNew pod startingOld pod terminatedNew pod readyNew pod startingOld pods terminatedAll pods running new version
Key Moments - 3 Insights
Why do we create new pods before deleting old pods?
Creating new pods first ensures the application stays available during the update, as shown in steps 2 and 3 where new pods start and become ready before old pods are deleted in step 4.
What happens if a new pod is not ready?
The update pauses until the new pod passes readiness checks, preventing deletion of old pods and avoiding downtime, as seen in the 'Wait for new pod ready' steps (3, 6, 9).
How do we know when the rolling update is complete?
When all old pods are deleted and all pods run the new version, as in step 11 where old pods count is 0 and new pods count is 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, how many new version pods exist after step 6?
A3
B1
C2
D0
💡 Hint
Check the 'Pods New Version' column at step 6 in the execution table.
At which step does the first old pod get deleted?
AStep 4
BStep 2
CStep 3
DStep 5
💡 Hint
Look for the first 'Old pod terminated' status in the execution table.
If new pods took longer to become ready, which step would be delayed?
ACreating new pods
BDeleting old pods
CStarting rolling update
DUpdate complete
💡 Hint
Refer to the 'Wait for new pod ready' steps before old pods are deleted.
Concept Snapshot
Rolling update strategy in Kubernetes:
- Gradually replace old pods with new pods
- Create new pods first, wait until ready
- Then delete old pods step-by-step
- Ensures zero downtime during updates
- Use 'kubectl set image' and 'kubectl rollout status' to manage
Full Transcript
The rolling update strategy in Kubernetes updates application pods gradually to avoid downtime. It starts by creating new pods with the updated version while keeping old pods running. Once new pods are ready, old pods are deleted one by one. This cycle repeats until all pods run the new version. Commands like 'kubectl set image' trigger the update, and 'kubectl rollout status' monitors progress. This method ensures continuous availability during updates.