Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
debugging K8s Networking Kubernetes Kubernetes: From Zero to Production Module 4 - Services and Networking

Networking Troubleshooting in Kubernetes

Reviewed & accurate
AI Summary

What You Will Learn

Intermediate

  • Common networking issues
  • Debugging tools and commands
  • A systematic process

Common Issues

ProblemCauseCheck
Cannot reach ServiceWrong selector, no Podskubectl get endpoints
DNS not resolvingCoreDNS downkubectl get pods -n kube-system
Pod cannot reach externalNo NAT/egressCheck node networking
Intermittent failuresPod not readykubectl 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.
Previously: Lesson 23 covered NetworkPolicies.
Today: You learned: Debug K8s networking issues.
Next: Lesson 25 covers CNI plugins.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments