What You Will Learn
Intermediate
- Common networking issues
- Debugging tools and commands
- A systematic process
Common Issues
| Problem | Cause | Check |
|---|---|---|
| Cannot reach Service | Wrong selector, no Pods | kubectl get endpoints |
| DNS not resolving | CoreDNS down | kubectl get pods -n kube-system |
| Pod cannot reach external | No NAT/egress | Check node networking |
| Intermittent failures | Pod not ready | kubectl describe pod |
Debugging Tools
Terminalbash
# 1. Check Service has endpoints (Pods)
kubectl get endpoints my-service
# If empty -> no matching Pods (check labels!)
# 2. DNS resolution from inside a Pod
kubectl exec -it my-pod -- nslookup my-service
# 3. Test connectivity
kubectl exec -it my-pod -- curl http://my-service
kubectl exec -it my-pod -- ping 10.0.0.1
# 4. Check CoreDNS
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system
# 5. Network debugging pod
kubectl run netshoot --rm -it --image=nicolaka/netshoot -- bash Practical Exercise
Create a Service with wrong selector
Check: kubectl get endpoints (should be empty)
Fix the selector to match Pod labels
Check again: endpoints should show Pod IPs
Use nslookup and curl to verify
Key Takeaways
- kubectl get endpoints: check if Service has Pods.
- nslookup from inside Pod: test DNS.
- curl from inside Pod: test connectivity.
- CoreDNS in kube-system: check DNS is running.
- Labels must match between Service selector and Pod labels.
Comments
Comments
Post a Comment