CKAD Dump 4 — Questions and Answers
Question 1: Which field in a CronJob spec controls how many successful job completions are retained?
- spec.jobTemplate.spec.completions
- spec.successfulJobsHistoryLimit (Correct answer)
- spec.retainJobs
- spec.historyLimit.success
Correct answer: spec.successfulJobsHistoryLimit
successfulJobsHistoryLimit specifies how many completed Job objects are kept; default is 3.
Question 2: You want to prevent pods in namespace 'dev' from communicating with pods in namespace 'prod'. Which resource do you use?
- ResourceQuota
- NetworkPolicy (Correct answer)
- PodSecurityPolicy
- LimitRange
Correct answer: NetworkPolicy
NetworkPolicy controls ingress and egress traffic between pods using label selectors and namespace selectors.
Question 3: What does the command 'kubectl rollout undo deployment/web' do?
- Deletes the deployment
- Rolls back to the previous revision (Correct answer)
- Pauses the rollout
- Scales down to zero replicas
Correct answer: Rolls back to the previous revision
kubectl rollout undo reverts the deployment to its previous revision by updating the pod template.
Question 4: Which volume type is best for sharing data between containers in the same pod during the pod's lifetime?
- persistentVolumeClaim
- hostPath
- emptyDir (Correct answer)
- configMap
Correct answer: emptyDir
emptyDir is created when the pod starts and lives as long as the pod, making it ideal for inter-container sharing.
Question 5: How do you expose port 8080 of a pod named 'myapp' as a ClusterIP Service named 'myapp-svc' imperatively?
- kubectl create service clusterip myapp-svc --tcp=80:8080
- kubectl expose pod myapp --port=80 --target-port=8080 --name=myapp-svc (Correct answer)
- kubectl service create myapp --port=8080
- kubectl apply service myapp-svc --pod=myapp
Correct answer: kubectl expose pod myapp --port=80 --target-port=8080 --name=myapp-svc
kubectl expose pod creates a Service targeting the specified pod port and exposes it on the given port.
Question 6: Which Kubernetes object automatically restarts failed pods and maintains a desired number of replicas without managing rollouts?
- Deployment
- StatefulSet
- ReplicaSet (Correct answer)
- DaemonSet
Correct answer: ReplicaSet
A ReplicaSet ensures the specified number of pod replicas are running but lacks rolling update strategies.
Question 7: A container's liveness probe fails repeatedly. What action does Kubernetes take?
- Evicts the pod from the node
- Removes the pod from Service endpoints
- Restarts the container according to restartPolicy (Correct answer)
- Cordons the node
Correct answer: Restarts the container according to restartPolicy
A failing liveness probe causes the kubelet to kill and restart the container based on the pod's restartPolicy.
Which field in a CronJob spec controls how many successful job completions are retained?