CKAD β Q03 (Question Statement)
Task:
Please complete the following:
-
Update the
appDeployment in thenov2025namespace with: -
maxSurge: 5% -
maxUnavailable: 5% -
Perform a rolling update of the
web1Deployment, changing the image version torepo/nginx:1.13 -
Rollback the
appDeployment to the previous version
π What the Question Is Asking
You are given a Deployment with:
- A rolling update strategy
- An image that needs to be changed
- A requirement to modify update strategy settings
- A requirement to rollback to the previous revision
This question tests:
- Your understanding of Deployment strategy fields
- Your understanding of revision history
- Your understanding of what triggers a revision
- Your understanding of what rollback actually reverts
π Core Kubernetes Truth (Must Remember for Exam)
π― Revision history is created ONLY when fields inside spec.template change.
That includes:
- Container image
- Env variables
- Commands
- Args
- Labels in pod template
- Volume mounts
- Container probes
- Annotations (template-level)
- Security context (container-level)
β Fields outside spec.template do NOT create revisions:
spec.strategyspec.revisionHistoryLimitspec.minReadySecondsspec.progressDeadlineSecondsspec.selectorspec.replicas
π Rollback ONLY restores spec.template
Rollback affects:
- image
- env
- labels
- mounts
- command/args
Rollback does NOT revert:
- strategy
- replicas
- selectors
- revisionHistoryLimit
- pause/resume status
This is why:
- You changed strategy β revision unchanged
- You changed image in the same edit β revision gets created
- Rollback restores image β strategy remains modified
π Three Valid Ways to Solve the Question (Exam Accepts All)
Method 1 β Edit Twice (Most Common Approach)
Step 1 β Change strategy
kubectl edit deployment app-deploy
Modify:
spec:
strategy:
rollingUpdate:
maxSurge: 50%
maxUnavailable: 50%
πΉ NO revision created because strategy is outside template.
Step 2 β Update image
kubectl set image deployment app-deploy myapp=nginx:1.19
πΉ Revision created now
Step 3 β Rollback
kubectl rollout undo deployment app-deploy
β Image goes back β Strategy does NOT revert
Method 2 β Edit Once (Combine Strategy + Image)
kubectl edit deployment app-deploy
You modify both:
- Strategy
- Image
What happens?
πΉ A revision is created πΉ BUT rollback still restores only the template (image) πΉ Strategy still stays modified
π‘ Because strategy is not revision-controlled
β This method is faster β 100% valid in exam β Behavior same as Method 1
Method 3 β kubectl patch
kubectl patch deployment app-deploy \
-p '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":"50%","maxUnavailable":"50%"}}}}'
πΉ No revision
Then:
kubectl set image deployment app-deploy myapp=nginx:1.19
πΉ Revision created
Rollback identical.
π EXAM TRAPS (Important)
Trap 1 β Thinking strategy triggers revision
β It does not. Only template changes trigger revision.
Trap 2 β Expecting rollback to revert strategy
β Strategy never rolls back.
Rollback only touches: spec.template fields.
Trap 3 β Doing everything in one kubectl edit and expecting full revert
Revert will: β Revert image β Not revert strategy β Not revert replicas β Not revert any spec outside template
Trap 4 β Forgetting rollout status
Always check:
kubectl rollout status deployment app-deploy
π FINAL EXAM WORKFLOW (Guaranteed 100% Correct)
Step-0: Check current revision
kubectl rollout history deployment app-deploy
Step-1: Modify strategy
kubectl edit deployment app-deploy
Add:
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 5%
maxUnavailable: 5%
Step-2: Update image
kubectl set image deployment app-deploy app=nginx:1.19
Step-3: Verify rollout
kubectl rollout status deployment app-deploy
Step-4: Undo
kubectl rollout undo deployment app-deploy
Step-5: Verify again
kubectl get deployment app-deploy -o yaml | grep strategy -A11
Image reverted β β Strategy unchanged β β
π Intellectually Complete Conclusion
- You can change strategy + image together.
- Revision will be created only because image (template) changed.
- Rollback will only revert template fields.
- Strategy will remain changed, no matter what.
- Behavior is identical whether you edit all at once or separately.
- Difference is only in rollout history description (
nonevs. βimage updatedβ).
You understood this perfectly β this is expert-level CKA/CKAD knowledge.
controlplane ~ β k create deploy abc --image nginx
deployment.apps/abc created
controlplane ~ β k rollout history deploy abc
deployment.apps/abc
REVISION CHANGE-CAUSE
1 <none>
controlplane ~ β k edit deploy abc # just spec.strategy is modified
deployment.apps/abc edited
controlplane ~ β k rollout history deploy abc # so, no revision triggered
deployment.apps/abc
REVISION CHANGE-CAUSE
1 <none>
controlplane ~ β k edit deploy abc # this time, image is updated
deployment.apps/abc edited
controlplane ~ β k rollout history deploy abc # revision is triggered
deployment.apps/abc
REVISION CHANGE-CAUSE
1 <none>
2 <none>
controlplane ~ β k rollout undo deploy abc
deployment.apps/abc rolled back
controlplane ~ β k rollout history deploy abc
deployment.apps/abc
REVISION CHANGE-CAUSE
2 <none>
3 <none>
controlplane ~ β k get deploy -o yaml abc | grep -i strategy -A11
strategy: # presevered
rollingUpdate:
maxSurge: 5%
maxUnavailable: 5%
type: RollingUpdate
template:
metadata:
labels:
app: abc
spec:
containers:
- image: nginx # reverted
controlplane ~ β k delete deploy abc
deployment.apps "abc" deleted from default namespace
controlplane ~ β k create deploy abc --image nginx
deployment.apps/abc created
controlplane ~ β k rollout history deploy abc
deployment.apps/abc
REVISION CHANGE-CAUSE
1 <none>
controlplane ~ β k edit deploy abc # modified both in one flow
deployment.apps/abc edited
controlplane ~ β k rollout history deploy abc # triggered, because image was updated
deployment.apps/abc
REVISION CHANGE-CAUSE
1 <none>
2 <none>
controlplane ~ β k rollout undo deploy abc
deployment.apps/abc rolled back
controlplane ~ β k rollout history deploy abc
deployment.apps/abc
REVISION CHANGE-CAUSE
2 <none>
3 <none>
controlplane ~ β k get deploy -o yaml abc | grep -i strategy -A11 # same behavior
strategy: # preserved
rollingUpdate:
maxSurge: 5%
maxUnavailable: 5%
type: RollingUpdate
template:
metadata:
labels:
app: abc
spec:
containers:
- image: nginx # reverted
controlplane ~ β