Short answer: CoreDNS answers names, Ingress carries outside HTTP requests
The three are not alternatives but different steps on a request's path. CoreDNS is the in-cluster DNS: it answers a Service name with a ClusterIP and never carries the request. A Service spreads connections sent to that virtual IP across Ready pods, at L4. An Ingress is a set of L7 rules that route outside HTTP(S) requests to Services by host and path; an Ingress controller does the actual work.
At a glance
- CoreDNS — name → ClusterIP · at DNS query time, before connecting · reads the Services · breaks as
no such host,i/o timeout - Service — ClusterIP:port → pod IP:targetPort · on every connection, via kube-proxy rules (iptables, IPVS) · reads endpoints built from the selector and readiness · breaks as: the name resolves, the connection fails
- Ingress — outside HTTP(S) → Service · at the edge, in the controller · reads Host, path and ingressClassName · breaks as 404 or 503 from outside only
How it actually works
Take a checkout Service (port: 80, targetPort: 8080) and an Ingress sending shop.example.com/api to it. Outside: public DNS returns the controller's load balancer (203.0.113.20) → the controller picks a rule → a pod. CoreDNS is not involved. Inside: CoreDNS returns the ClusterIP → kube-proxy rules → a pod.
$ nslookup checkout.shop.svc.cluster.local # from inside a pod
Name: checkout.shop.svc.cluster.local
Address: 10.96.112.40
$ kubectl -n shop get endpoints checkout
NAME ENDPOINTS AGE
checkout 10.244.1.23:8080,10.244.2.11:8080 30d
$ kubectl -n shop get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
shop nginx shop.example.com 203.0.113.20 80 12d
An Address equal to the Service's ClusterIP means CoreDNS works. Pod IPs on 8080 under ENDPOINTS mean the Service works. Filled-in CLASS and ADDRESS mean a controller owns the Ingress.
When to use which
- Calls inside the cluster → the Service name (
checkout.shopacross namespaces). The Ingress address loops out through the load balancer and back. - Many HTTP(S) services split by domain and path, with TLS in one place → Ingress (or a Gateway API HTTPRoute).
- Non-HTTP TCP or UDP from outside → a LoadBalancer or NodePort Service.
Failure 1: the name does not resolve — the CoreDNS step
dial tcp: lookup checkout on 10.96.0.10:53: no such host
dial tcp: lookup checkout.shop.svc.cluster.local: i/o timeout
A lookup error comes before any connection. If curl to the ClusterIP works from the same pod, it is the CoreDNS side. no such host usually means a wrong name, often a Service in another namespace called by its short name. i/o timeout means the query never reached CoreDNS, typically a NetworkPolicy blocking port 53. See CoreDNS running but DNS fails.
Failure 2: the name resolves but the connection fails — the Service step
A Service that is not headless resolves even with zero pods. If the ClusterIP gives connection refused or a timeout, check the endpoints, not CoreDNS.
$ kubectl -n shop get endpoints checkout
NAME ENDPOINTS AGE
checkout <none> 30d
Empty means no Ready pod matches the selector: look for changed labels (--show-labels) or Ready: False. Pod IPs listed but still failing points to the targetPort (Pod Running but Service traffic fails).
Failure 3: 404 or 503 from outside only — the Ingress step
If curl http://checkout.shop works inside the cluster, the first two steps pass. Ask the controller directly.
curl -i -H "Host: shop.example.com" http://203.0.113.20/api/healthz
- The nginx default 404 → no rule matched: host, class or path (Ingress 404 Not Found)
- 503 → a rule matched but there is no pod to send to: back to failure 2
What not to do
- Restarting CoreDNS first — if the name resolves to the ClusterIP, DNS has done its job.
- Pinging the ClusterIP — it is virtual and does not answer ping in iptables mode. Curl the port.
Summary
- Read the error:
lookup→ CoreDNS, refused or timeout → Service, 404 or 503 → Ingress - Works by ClusterIP → the DNS path; fails by IP too →
kubectl get endpoints, selector, readiness, targetPort - Fails only from outside →
curl -H "Host: ..."to the controller: 404 is the rules, 503 the endpoints
To practise finding the guilty step, try A pod is Running and one Service still has no endpoints.
Quick diagnostic checklist
- First decide whether the error is a
lookupfailure (no such host, i/o timeout), a connection failure, or an HTTP 404 or 503. - From the failing pod, call the name and the ClusterIP separately; if only the IP works, follow the CoreDNS path.
- On
no such host, check the Service name and namespace (a short name resolves only within the caller's namespace). - On
i/o timeout, check that egress NetworkPolicy allows UDP and TCP 53 to kube-system. - If the name resolves to the ClusterIP but connections fail, check whether
kubectl get endpointsis empty. - If the endpoints are empty, compare the Service selector with the pod labels and check the pods' Ready status.
- If it fails only from outside, send
curl -H "Host: ..."straight to the controller and see whether it is a 404 or a 503. - Check that HOSTS, CLASS and ADDRESS in
kubectl get ingressmatch the requested address and the controller you expect.