🧠 Kubernetes Service Connectivity: nslookup vs curl

This guide explains the difference between nslookup and curl when testing Kubernetes Services β€” what each one checks, when to use which, and how to interpret the results during CKAD/CKA exams.


🧩 1. The Two Layers of Service Access

When you test a Kubernetes Service from inside a pod, you’re checking two separate layers:

Tool Layer Tested Purpose
nslookup DNS (CoreDNS) Checks if the Service name resolves to a ClusterIP
curl Network + Application Checks if traffic can reach the Service and the app responds

βš™οΈ 2. Example Commands

βœ… DNS Test

nslookup nginx-svc.default.svc.cluster.local
Checks: - Can the pod resolve the Service name using CoreDNS? - Is DNS properly configured in the cluster?

Example output:

Name:   nginx-svc.default.svc.cluster.local
Address: 10.96.12.101
βœ… DNS resolution works.


βœ… Application Test

curl nginx-svc.default:80
Checks: - Can the pod reach the Service ClusterIP on port 80? - Are kube-proxy and service routing working? - Are backend pods responding?

Example output (for Nginx):

<html>
<head><title>Welcome to nginx!</title></head>
<body>...</body>
</html>
βœ… Application reachable and responding.


🧠 3. Difference in Depth

Command What it Tests What Success Means
nslookup svc-name.ns.svc.cluster.local CoreDNS DNS resolution Service name β†’ ClusterIP works
curl svc-name.ns:port Network + application path Service + Pod connectivity works

Analogy:

  • nslookup = finding someone’s phone number πŸ“ž
  • curl = actually calling them and getting a reply πŸ‘‹

🧩 4. How Kubernetes Resolves Names

Inside any pod, /etc/resolv.conf includes:

search ns.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.96.0.10

When you type:

curl amor.amor:80
CoreDNS automatically expands it to:
amor.amor.svc.cluster.local
So you can use short or full DNS forms interchangeably.


🧰 5. How to Interpret Results in Exams

nslookup Result curl Result Meaning
βœ… Works βœ… Works Everything is healthy
❌ Fails ❌ Fails DNS/CoreDNS issue
βœ… Works ❌ Fails NetworkPolicy issue / wrong target port / no endpoints
❌ Fails βœ… Works Misconfiguration (rare)

🧩 6. Example CKAD Workflow

# Step 1: DNS Resolution Test
kubectl exec testpod -n alpha -- nslookup nginx-svc.alpha.svc.cluster.local

# Step 2: Application Connectivity Test
kubectl exec testpod -n alpha -- curl nginx-svc.alpha:80

Result Meaning:

  • Both βœ… β†’ Service fully functional
  • nslookup βœ… but curl ❌ β†’ Routing or app issue
  • Both ❌ β†’ DNS/CoreDNS issue

⚑ 7. Common Exam Scenarios

Exam Prompt You Should Run Layer Tested
β€œVerify if service name resolves” nslookup svc-name.ns.svc.cluster.local DNS
β€œCheck if the pod can access the service” curl svc-name.ns:port Application
β€œService resolves but not reachable” Both commands DNS + Network
β€œPods can’t reach app even though DNS works” curl only NetworkPolicy or wrong port

🧠 8. Flowchart for Debugging

                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ Run nslookup             β”‚
                β”‚ (Check DNS resolution)   β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚                       β”‚
               Works βœ…               Fails ❌
                  β”‚                       β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Run curl          β”‚        β”‚ Fix DNS/CoreDNS β”‚
        β”‚ (Check app reach) β”‚        β”‚ or Service name β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚                β”‚
        Works βœ…         Fails ❌
          β”‚                β”‚
          β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚     β”‚ Check NetworkPolicy  β”‚
          β”‚     β”‚ Ports / Endpoints    β”‚
          β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧭 9. Quick Reference Table

Test Goal Command What It Proves
Check DNS resolution nslookup svc-name.ns.svc.cluster.local CoreDNS is resolving names
Check Service routing curl svc-name.ns:port Service forwards traffic correctly
Check ClusterIP access curl <ClusterIP>:<port> Network path works (bypass DNS)
Test both layers Run both commands Full connectivity verified

❀️ 10. Summary (for CKAD Mindset)

Command Focus Layer
nslookup β€œCan I find the service?” DNS (CoreDNS)
curl β€œCan I reach and talk to it?” Network + App

Rule of thumb:

πŸ”Ή If nslookup fails β†’ DNS problem.
πŸ”Ή If nslookup works but curl fails β†’ NetworkPolicy or wrong port.
πŸ”Ή If both work β†’ everything is fine.