Bird
Raised Fist0
Kubernetesdevops~10 mins

Rolling update strategy in Kubernetes - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the rolling update strategy type in a Kubernetes deployment.

Kubernetes
strategy:
  type: [1]
Drag options to blanks, or click blank then click option'
ARecreate
BRollingUpdate
CBlueGreen
DCanary
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Recreate' which stops all old pods before starting new ones.
Using 'BlueGreen' or 'Canary' which are not native Kubernetes strategy types.
2fill in blank
medium

Complete the code to set the maximum number of pods that can be unavailable during a rolling update.

Kubernetes
strategy:
  rollingUpdate:
    maxUnavailable: [1]
Drag options to blanks, or click blank then click option'
A50%
B0
C25%
D100%
Attempts:
3 left
💡 Hint
Common Mistakes
Setting maxUnavailable to 0 which means no downtime allowed.
Setting maxUnavailable to 100% which would stop all pods.
3fill in blank
hard

Fix the error in the rolling update configuration by completing the missing field.

Kubernetes
strategy:
  rollingUpdate:
    maxSurge: [1]
Drag options to blanks, or click blank then click option'
A2
Btwo
C200%
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a word like 'two' instead of a number.
Using negative numbers which are invalid.
Using percentages over 100% which is not allowed.
4fill in blank
hard

Fill both blanks to configure a rolling update with 1 max surge and 0 max unavailable pods.

Kubernetes
strategy:
  rollingUpdate:
    maxSurge: [1]
    maxUnavailable: [2]
Drag options to blanks, or click blank then click option'
A1
B0
C25%
D50%
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping maxSurge and maxUnavailable values.
Using percentages when integers are expected.
5fill in blank
hard

Fill all three blanks to create a deployment spec with rolling update strategy, max surge 2, and max unavailable 25%.

Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
spec:
  replicas: 3
  strategy:
    type: [1]
    rollingUpdate:
      maxSurge: [2]
      maxUnavailable: [3]
Drag options to blanks, or click blank then click option'
ARollingUpdate
B2
C25%
DRecreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Recreate' instead of 'RollingUpdate' for strategy type.
Mixing up maxSurge and maxUnavailable values.

Practice

(1/5)
1. What is the main purpose of a rolling update in Kubernetes?
easy
A. To update an application without downtime by gradually replacing pods
B. To delete all pods and recreate them at once
C. To backup the current state of the application
D. To scale the application to zero replicas

Solution

  1. Step 1: Understand rolling update concept

    A rolling update replaces pods one by one to avoid downtime.
  2. Step 2: Compare options with concept

    Only To update an application without downtime by gradually replacing pods describes gradual replacement without downtime.
  3. Final Answer:

    To update an application without downtime by gradually replacing pods -> Option A
  4. Quick Check:

    Rolling update = gradual pod replacement [OK]
Hint: Rolling update means update pods one by one without downtime [OK]
Common Mistakes:
  • Thinking rolling update deletes all pods at once
  • Confusing rolling update with backup
  • Assuming rolling update scales pods to zero
2. Which kubectl command starts a rolling update by changing the image of a deployment?
easy
A. kubectl set image deployment/myapp myapp-container=myimage:v2
B. kubectl rollout undo deployment/myapp
C. kubectl scale deployment/myapp --replicas=0
D. kubectl get pods --watch

Solution

  1. Step 1: Identify command to update image

    The command to update a deployment's image is 'kubectl set image'.
  2. Step 2: Match command with options

    kubectl set image deployment/myapp myapp-container=myimage:v2 uses 'kubectl set image' correctly to start rolling update.
  3. Final Answer:

    kubectl set image deployment/myapp myapp-container=myimage:v2 -> Option A
  4. Quick Check:

    Change image = kubectl set image [OK]
Hint: Use kubectl set image to start rolling update [OK]
Common Mistakes:
  • Using rollout undo to start update
  • Scaling replicas to zero instead of updating image
  • Using get pods to update image
3. After running kubectl set image deployment/myapp myapp-container=myimage:v2, what does kubectl rollout status deployment/myapp show?
medium
A. The configuration details of the deployment
B. The current rollout progress of the deployment update
C. The logs of the deployment pods
D. The list of pods in the deployment

Solution

  1. Step 1: Understand purpose of rollout status

    The command 'kubectl rollout status' shows progress of deployment updates.
  2. Step 2: Compare options with command purpose

    The current rollout progress of the deployment update correctly describes rollout progress; others describe different commands.
  3. Final Answer:

    The current rollout progress of the deployment update -> Option B
  4. Quick Check:

    Rollout status = update progress [OK]
Hint: Rollout status shows update progress, not pod list or logs [OK]
Common Mistakes:
  • Confusing rollout status with pod listing
  • Expecting logs from rollout status
  • Thinking rollout status shows config details
4. You ran kubectl set image deployment/myapp myapp-container=myimage:v2 but the new pods crash. Which command helps you revert to the previous version?
medium
A. kubectl scale deployment/myapp --replicas=0
B. kubectl delete deployment myapp
C. kubectl rollout undo deployment/myapp
D. kubectl get pods --all-namespaces

Solution

  1. Step 1: Identify command to revert deployment

    'kubectl rollout undo' reverts deployment to previous version.
  2. Step 2: Match command with options

    kubectl rollout undo deployment/myapp correctly reverts the deployment; others do not revert updates.
  3. Final Answer:

    kubectl rollout undo deployment/myapp -> Option C
  4. Quick Check:

    Undo rollout = kubectl rollout undo [OK]
Hint: Use rollout undo to revert bad updates quickly [OK]
Common Mistakes:
  • Deleting deployment instead of undoing
  • Scaling replicas to zero instead of reverting
  • Using get pods which only lists pods
5. You want to update your deployment with zero downtime and ensure at least 2 pods are always available during the update. Which rolling update settings in the deployment spec help achieve this?
hard
A. Set 'maxUnavailable' to 1 and 'maxSurge' to 1 in 'rollingUpdate' strategy
B. Set 'maxUnavailable' to 2 and 'maxSurge' to 0 in 'rollingUpdate' strategy
C. Set 'maxUnavailable' to 3 and 'maxSurge' to 3 in 'rollingUpdate' strategy
D. Set 'maxUnavailable' to 0 and 'maxSurge' to 2 in 'rollingUpdate' strategy

Solution

  1. Step 1: Understand maxUnavailable and maxSurge

    'maxUnavailable' controls how many pods can be down; 'maxSurge' controls extra pods created during update.
  2. Step 2: Ensure at least 2 pods always available

    Setting 'maxUnavailable' to 0 means no pods go down; 'maxSurge' 2 allows 2 extra pods to be created for smooth update.
  3. Final Answer:

    Set 'maxUnavailable' to 0 and 'maxSurge' to 2 in 'rollingUpdate' strategy -> Option D
  4. Quick Check:

    Zero unavailable + surge 2 = no downtime, 2 pods always up [OK]
Hint: maxUnavailable 0 means no pod down; maxSurge adds extra pods [OK]
Common Mistakes:
  • Setting maxUnavailable > 0 causes downtime
  • Setting maxSurge to 0 prevents extra pods during update
  • Choosing high maxUnavailable and maxSurge causing instability
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard