Hint: Use '--' before command in kubectl exec to run inside pod [OK]
Common Mistakes:
Omitting '--' which causes command to fail
Using '-it' without need for interactive shell
Using curl instead of nslookup for DNS test
3. You run kubectl describe svc myservice and see no endpoints listed. What will be the output of kubectl get endpoints myservice?
medium
A. Error from server (NotFound): endpoints "myservice" not found
B. NAME ENDPOINTS AGE
myservice 10.0.0.5:80,10.0.0.6:80 10m
C. NAME ENDPOINTS AGE
myservice 127.0.0.1:80 10m
D. NAME ENDPOINTS AGE
myservice <none> 10m
Solution
Step 1: Interpret service describe output
No endpoints means no pods are linked to the service, so endpoints list is empty.
Step 2: Predict endpoints output
kubectl get endpoints myservice will show the service name with <none> under ENDPOINTS.
Final Answer:
NAME ENDPOINTS AGE
myservice <none> 10m -> Option D
Quick Check:
No endpoints = <none> shown [OK]
Hint: No endpoints in describe means endpoints show <none> [OK]
Common Mistakes:
Assuming endpoints will list IPs even if none exist
Expecting an error when endpoints exist but are empty
Confusing endpoints with pod IPs
4. A pod cannot reach a service by its DNS name. You run kubectl exec pod1 -- nslookup myservice and get a timeout. What is the most likely cause?
medium
A. The pod is missing the DNS policy or DNS is misconfigured
B. The service has no endpoints, so DNS resolves but no response
C. The service selector labels do not match any pods
D. The pod is running in a different namespace without DNS search path
Solution
Step 1: Analyze DNS timeout symptom
A DNS timeout means the pod cannot resolve the service name, indicating DNS issues.
Step 2: Identify DNS misconfiguration causes
Missing DNS policy or broken DNS config in pod causes nslookup timeout, unlike no endpoints which still resolve DNS.
Final Answer:
The pod is missing the DNS policy or DNS is misconfigured -> Option A
Quick Check:
DNS timeout = DNS config issue [OK]
Hint: DNS timeout means DNS config or policy problem, not endpoints [OK]
Common Mistakes:
Confusing DNS resolution failure with no endpoints
Assuming label mismatch causes DNS timeout instead of no response
Ignoring namespace DNS search path issues
5. You have a service myservice in namespace prod. A pod in namespace dev tries to connect using curl myservice but fails. Which is the best way to debug this connectivity issue?
hard
A. Run kubectl describe pod -n prod myservice to check pod details
B. Run kubectl exec -n dev pod -- curl myservice.prod.svc.cluster.local to test full DNS name
C. Run kubectl get svc -n dev myservice to check service in dev namespace
D. Run kubectl exec -n prod pod -- curl myservice to test from the service namespace
Solution
Step 1: Understand cross-namespace service access
Pods in different namespaces must use the full DNS name including namespace to reach a service.
Step 2: Test connectivity using full DNS name from the pod in dev namespace
Running kubectl exec -n dev pod -- curl myservice.prod.svc.cluster.local tests correct DNS and connectivity.
Final Answer:
Run kubectl exec -n dev pod -- curl myservice.prod.svc.cluster.local to test full DNS name -> Option B
Quick Check:
Cross-namespace access needs full DNS name [OK]
Hint: Use full DNS name with namespace for cross-namespace service access [OK]
Common Mistakes:
Trying to curl service without namespace from another namespace