CKA Application Lifecycle 2 — Questions and Answers
Question 1: A Deployment has 5 replicas and you run `kubectl rollout pause deployment/myapp`. What happens to an in-progress rolling update?
- The update completes before pausing
- The update is immediately rolled back
- The update halts at its current state until resumed (Correct answer)
- All pods restart simultaneously
Correct answer: The update halts at its current state until resumed
Pausing a rollout freezes the update mid-progress; new pods already created remain, but no further pod replacements occur until `kubectl rollout resume` is run.
Question 2: Which field in a Deployment spec controls the maximum number of pods that can be unavailable during a rolling update?
- maxSurge
- maxUnavailable (Correct answer)
- minReadySeconds
- revisionHistoryLimit
Correct answer: maxUnavailable
`maxUnavailable` defines how many pods can be taken down simultaneously during a rolling update, expressed as an absolute number or percentage.
Question 3: You need to update a Deployment's image without triggering a rollout. Which approach achieves this?
- Use `kubectl set image` with --record=false
- Edit the Deployment spec and set spec.paused: true first (Correct answer)
- Change the image in a ConfigMap referenced by the Deployment
- Modify spec.template.metadata.annotations only
Correct answer: Edit the Deployment spec and set spec.paused: true first
Pausing the Deployment before editing the image prevents Kubernetes from starting a rollout; the change is saved but not applied until the Deployment is resumed.
Question 4: A pod's init container exits with code 0. What does Kubernetes do next?
- Restarts the init container per restartPolicy
- Starts the next init container or the main app container (Correct answer)
- Marks the pod as Failed
- Runs all remaining init containers in parallel
Correct answer: Starts the next init container or the main app container
An exit code of 0 signals success; Kubernetes then starts the next init container in order, or starts the main application containers if all init containers have completed.
Question 5: What is the effect of setting `spec.strategy.type: Recreate` in a Deployment?
- Pods are updated one at a time with zero downtime
- All existing pods are terminated before new pods are created (Correct answer)
- New pods are created first, then old pods are deleted
- Pods are updated using a blue/green strategy
Correct answer: All existing pods are terminated before new pods are created
The Recreate strategy terminates all existing pods first, causing downtime, then creates the new version pods — useful when running two versions simultaneously is not acceptable.
Question 6: Which kubectl command shows the rollout history of a Deployment including change-cause annotations?
- kubectl describe deployment myapp
- kubectl rollout history deployment/myapp (Correct answer)
- kubectl get replicaset -l app=myapp
- kubectl logs deployment/myapp
Correct answer: kubectl rollout history deployment/myapp
`kubectl rollout history deployment/myapp` lists revision numbers and their CHANGE-CAUSE annotations, which are recorded when `--record` flag or the annotation is set.
Question 7: A Deployment with `revisionHistoryLimit: 3` has been updated 10 times. How many old ReplicaSets are retained?
- 10
- 9
- 3 (Correct answer)
- 1
Correct answer: 3
`revisionHistoryLimit` controls how many old ReplicaSets (representing previous revisions) are kept for rollback; older ones beyond this limit are garbage-collected.
A Deployment has 5 replicas and you run `kubectl rollout pause deployment/myapp`.
What happens to an in-progress rolling update?