CKA CKA Workload Management and Scheduling 1 — Questions and Answers
Question 1: What is the relationship between a Deployment and a ReplicaSet in Kubernetes?
- A Deployment replaces ReplicaSets entirely
- A Deployment creates and manages ReplicaSets to achieve rolling updates and rollbacks (Correct answer)
- A ReplicaSet manages multiple Deployments
- They are identical objects with different names
Correct answer: A Deployment creates and manages ReplicaSets to achieve rolling updates and rollbacks
A Deployment manages one or more ReplicaSets and coordinates rolling updates by creating a new ReplicaSet and scaling it up while scaling down the old one.
Question 2: Which kubectl command triggers a rolling update on a Deployment by changing its container image?
- kubectl apply -f deployment.yaml
- kubectl set image deployment/<name> <container>=<new-image> (Correct answer)
- kubectl rollout restart deployment/<name>
- kubectl edit replicaset <name>
Correct answer: kubectl set image deployment/<name> <container>=<new-image>
The `kubectl set image` command updates a container's image in a running Deployment, triggering a rolling update automatically.
Question 3: How do you roll back a Deployment to its previous revision in Kubernetes?
- kubectl delete deployment <name>
- kubectl rollout undo deployment/<name> (Correct answer)
- kubectl revert deployment/<name>
- kubectl scale deployment/<name> --replicas=0
Correct answer: kubectl rollout undo deployment/<name>
The `kubectl rollout undo deployment/<name>` command reverts the Deployment to its previous revision by scaling up the old ReplicaSet.
Question 4: What does the 'maxSurge' field in a Deployment's rolling update strategy control?
- The maximum number of Pods that can be unavailable during an update
- The maximum number of extra Pods that can exist above the desired replica count during an update (Correct answer)
- The maximum number of failed Pods before the rollout stops
- The maximum CPU usage allowed during a rollout
Correct answer: The maximum number of extra Pods that can exist above the desired replica count during an update
maxSurge sets how many additional Pods beyond the desired count may run simultaneously during a rolling update, allowing new Pods to start before old ones terminate.
Question 5: Which command shows the rollout history of a Kubernetes Deployment?
- kubectl log deployment/<name>
- kubectl rollout history deployment/<name> (Correct answer)
- kubectl describe deployment/<name>
- kubectl get events --field-selector=involvedObject.kind=Deployment
Correct answer: kubectl rollout history deployment/<name>
The `kubectl rollout history deployment/<name>` command lists previous revisions of the Deployment along with their change causes.
Question 6: What is the purpose of the 'minReadySeconds' field in a Deployment spec?
- Sets the minimum time a container must run before probes start
- Specifies how many seconds a new Pod must be ready before it is considered available (Correct answer)
- Limits how quickly new Pods can be created during a rollout
- Defines the grace period for Pod termination
Correct answer: Specifies how many seconds a new Pod must be ready before it is considered available
minReadySeconds defines the minimum time (after a Pod becomes ready) that must elapse before the Pod is counted as available, preventing hasty rollout progression.
What is the relationship between a Deployment and a ReplicaSet in Kubernetes?