Course contentsShow
← Cloud and Infrastructure
Lesson 1218 of 2,98924. Kubernetes NetworkingFree lesson

Service Debugging and Troubleshooting

Using kubectl and DNS queries to diagnose Service connectivity and endpoint registration issues.

Service Debugging and Troubleshooting

You'll learn how to diagnose and fix Service connectivity problems using kubectl and DNS queries to verify that traffic reaches the right Pods.

What Happens When Services Don't Work?

When applications can't connect through a Service, it's like having a phone number that doesn't ring anywhere. The issue could be with the "phone book" (DNS), the "routing" (Service configuration), or the "destinations" (Pod endpoints). Kubernetes gives you tools to check each layer.

Using kubectl to Debug Services

Start by checking if the Service exists and has endpoints:

kubectl get service my-service
kubectl describe service my-service

The describe output shows the Endpoints section—these are the actual Pod IPs the Service routes to. If this list is empty, your Service's selector doesn't match any running Pods.

Check the Endpoints object directly:

kubectl get endpoints my-service

Verify your Pods have the correct labels:

kubectl get pods --show-labels

Compare these labels with your Service's selector from kubectl describe service.

DNS Debugging

Services should be resolvable by DNS. Test from inside a Pod:

kubectl run test-pod --image=busybox -it --rm -- nslookup my-service

This should return the Service's ClusterIP. If DNS fails, the problem might be with CoreDNS or the Service name itself.

For cross-namespace access, use the full DNS name: my-service.my-namespace.svc.cluster.local.

Common Issues

  • No endpoints: Label mismatch between Service selector and Pods
  • DNS fails: Service name typo or CoreDNS problem
  • Endpoints exist but traffic fails: Check Pod readiness and target ports

Key Takeaway: Service debugging follows a checklist—verify the Service exists, confirm it has endpoints matching your Pods' labels, test DNS resolution, and validate port configurations using kubectl describe and DNS queries.