CKAD – Q03 (Question Statement)

Task:

Please complete the following:

  1. Update the app Deployment in the nov2025 namespace with:

  2. maxSurge: 5%

  3. maxUnavailable: 5%

  4. Perform a rolling update of the web1 Deployment, changing the image version to repo/nginx:1.13

  5. Rollback the app Deployment 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:

  1. Your understanding of Deployment strategy fields
  2. Your understanding of revision history
  3. Your understanding of what triggers a revision
  4. 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.strategy
  • spec.revisionHistoryLimit
  • spec.minReadySeconds
  • spec.progressDeadlineSeconds
  • spec.selector
  • spec.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

  1. You can change strategy + image together.
  2. Revision will be created only because image (template) changed.
  3. Rollback will only revert template fields.
  4. Strategy will remain changed, no matter what.
  5. Behavior is identical whether you edit all at once or separately.
  6. Difference is only in rollout history description (none vs. β€œ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 ~ ➜