CKA Troubleshooting Practice Question
You need to test DNS resolution from within a pod. Which command should you run?
⚠ Common exam trap
It's easy for candidates to choose Option D because it seems like a quick way to run a DNS test without needing an existing pod, but they overlook that creating a new pod can introduce different DNS settings (e.g., default `dnsPolicy: ClusterFirst` vs. a pod with `dnsPolicy: Default`) and that the pod must be cleaned up manually, whereas Option C directly tests the actual pod's DNS resolution without side effects.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
kubectl exec <pod> -- nslookup <service-name>
`kubectl exec <pod> -- nslookup <service-name>` runs the `nslookup` command directly inside an existing pod, which tests DNS resolution from within the pod's network namespace. This is the most direct way to verify that the pod's DNS resolver (typically CoreDNS or kube-dns) can resolve a Kubernetes service name to a cluster IP, as it uses the pod's `/etc/resolv.conf` and the cluster DNS service.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
kubectl describe svc <service-name>
Why it's wrong here
This command retrieves the configuration details of a Service object, such as its ClusterIP, ports, and endpoints, from the Kubernetes API server. While it helps verify that the Service exists and is configured correctly, it does not execute any network or DNS resolution queries from the perspective of a running pod. To test actual DNS resolution, you must execute a query tool like nslookup or dig from within the container network namespace.
- ✗
kubectl logs <pod> | grep dns
Why it's wrong here
This command inspects the standard output and standard error streams of the specified pod, filtering for the term "dns". However, application pods do not typically log internal DNS resolution queries or failures unless specifically configured with verbose debugging. Consequently, this approach is highly unreliable for active troubleshooting and does not trigger a real-time DNS lookup to verify CoreDNS functionality.
- ✓
kubectl exec <pod> -- nslookup <service-name>
Why this is correct
This command uses kubectl exec to run the nslookup utility directly inside the container of an existing pod, utilizing its specific network namespace and /etc/resolv.conf configuration. By querying the target service name from within the pod, you can accurately verify if the pod's configured DNS resolver (typically CoreDNS) is functioning and resolving names correctly. This is the standard method for diagnosing pod-level DNS resolution issues in a Kubernetes cluster.
- ✗
kubectl run nslookup --image=busybox -- nslookup <service-name>
Why it's wrong here
This command provisions a brand-new, temporary pod to run the DNS query, which does not help diagnose issues specific to the existing pod's environment. If the original pod has unique network policies, a misconfigured /etc/resolv.conf, or resides in a different namespace with distinct DNS search paths, spinning up a new pod will bypass and fail to isolate those specific local configuration issues.
Visual reference
Go deeper
Related to this question
Learn chapter
Kubernetes Architecture Overview
Key term
Ingress Resources
Ingress Resources are Kubernetes API objects that manage external access to services inside a cluster, typically HTTP and HTTPS traffic, by defining rules for routing requests based on hostnames and paths.
Key term
kubectl Command Reference
kubectl is the command-line tool used to interact with and manage Kubernetes clusters by sending commands to the Kubernetes API.
About these practice questions
One of 726 original CKA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.