CKAD CKAD 2 — Questions and Answers
Question 1: Which command creates a ConfigMap named 'app-config' from a literal key-value pair KEY=value?
- kubectl create configmap app-config --from-literal=KEY=value (Correct answer)
- kubectl create configmap app-config --literal KEY=value
- kubectl apply configmap app-config --key=KEY --value=value
- kubectl set configmap app-config KEY=value
Correct answer: kubectl create configmap app-config --from-literal=KEY=value
The --from-literal flag is used with kubectl create configmap to define key-value pairs inline.
Question 2: A Pod is in 'CrashLoopBackOff' state. Which command is most useful for diagnosing the root cause?
- kubectl describe pod <pod-name>
- kubectl logs <pod-name> --previous (Correct answer)
- kubectl exec <pod-name> -- /bin/sh
- kubectl get events --field-selector reason=BackOff
Correct answer: kubectl logs <pod-name> --previous
kubectl logs --previous retrieves logs from the last terminated container instance, which reveals why it crashed.
Question 3: Which Kubernetes object should you use to expose a set of Pods internally within the cluster on a stable DNS name and IP?
- Ingress
- NodePort Service
- ClusterIP Service (Correct answer)
- ExternalName Service
Correct answer: ClusterIP Service
A ClusterIP Service provides a stable internal IP and DNS name for accessing Pods within the cluster.
Question 4: What is the effect of setting 'imagePullPolicy: Never' on a container spec?
- Kubernetes pulls the image only if it is not already cached locally
- Kubernetes always pulls the latest version of the image
- Kubernetes uses only a locally present image and fails if it is absent (Correct answer)
- Kubernetes disables image updates for that container permanently
Correct answer: Kubernetes uses only a locally present image and fails if it is absent
imagePullPolicy: Never instructs the kubelet to use only a pre-existing local image, returning an error if it is not found.
Question 5: A Deployment must ensure at least 3 Pods are available during a rolling update. Which field controls this?
- strategy.rollingUpdate.maxSurge
- strategy.rollingUpdate.maxUnavailable (Correct answer)
- spec.minReadySeconds
- spec.progressDeadlineSeconds
Correct answer: strategy.rollingUpdate.maxUnavailable
maxUnavailable defines how many Pods can be down simultaneously during a rolling update, ensuring availability minimums are maintained.
Question 6: Which command applies a label 'env=prod' to a running Pod named 'web-pod'?
- kubectl annotate pod web-pod env=prod
- kubectl label pod web-pod env=prod (Correct answer)
- kubectl set label pod web-pod env=prod
- kubectl patch pod web-pod --label env=prod
Correct answer: kubectl label pod web-pod env=prod
kubectl label is the correct imperative command for adding or modifying labels on Kubernetes resources.
Question 7: What does a liveness probe do when it repeatedly fails for a container?
- Removes the Pod from Service endpoints
- Restarts the container (Correct answer)
- Deletes and recreates the Pod
- Sends an alert to the cluster administrator
Correct answer: Restarts the container
A failing liveness probe causes the kubelet to restart the container, not the entire Pod.
Which command creates a ConfigMap named 'app-config' from a literal key-value pair KEY=value?