Skip to main content
Kubernetes coreLesson 8 of 13

Finding Services by Name (Service·DNS)

The web pod in the shop namespace calls the order service order-svc. Let's follow how it gets there by name alone, without knowing any IP, and the cases where name lookup fails.

Name calledorder-svc
Full name resolved—
Address returned—
ResultLooking up
kube-systemNamespace opsNamespace shopwebPod in shopCoreDNSCluster DNSorder-svc10.96.12.34order-a10.244.1.5order-b10.244.2.7adminPod in opsorder-svc?
RequestResponse / reportAppears in a later step

What you will learn

  • How a Service name becomes a DNS name
  • Why short names work only in the same namespace
  • Where the Service virtual IP turns into a pod
  • What a name typo and a DNS outage look like

Find where it stopped by the symptom​

Symptom in the appWhere it stoppedCommon causes
Name not found (host not found)DNS lookupTypo in the Service name, calling a Service in another namespace by its short name
Name lookup fails with no response, but the IP worksDNS serverCoreDNS outage, a network policy blocking DNS (port 53) lookups
Name resolves but connection failsService → podSelector and pod labels do not match so there are 0 target pods, port mismatch

Try it yourself​

kubectl get svc -n <namespace> # Service names and CLUSTER-IP
kubectl get endpointslices -n <namespace> -l kubernetes.io/service-name=<service> # Pod IPs behind the Service
kubectl exec <pod> -- cat /etc/resolv.conf # search list, own namespace first
kubectl run dns-test --image=busybox:1.36 --rm -it --restart=Never -- nslookup <service>.<namespace> # Throwaway Pod, removed on exit
kubectl get pods -n kube-system -l k8s-app=kube-dns # Is CoreDNS healthy?

Check yourself

  1. The admin pod in namespace ops calls the short name order-svc, which lives in namespace shop, and gets "name not found". Why?
  2. Calling a Service by IP works, but calling it by name fails with no response. What should you suspect first?
  3. ping to a Service's ClusterIP gets no reply. What does that tell you?

Further reading: Service · DNS for Services and Pods