Services, Ingress & DNS

ClusterIP vs NodePort vs LoadBalancer, Ingress controllers, CoreDNS. Trace a request from the internet to a pod.

About 29 min read3-question knowledge check

The mental model

Pods are cattle with disposable IP addresses. Every restart gives a pod a new IP, so nothing can talk to a pod by address and stay correct. Kubernetes networking exists to put stable names and stable virtual addresses in front of unstable pods, and then to let traffic from outside the cluster find them.

The analogy that sticks: a large office building.

  • A Pod IP is an employee's desk position. It changes whenever they move.
  • A Service is the department's internal extension number — dial "Accounts" and the switchboard connects you to whoever is on duty. The extension never changes; the humans behind it do.
  • CoreDNS is the internal directory that turns "Accounts" into that extension.
  • An Ingress (or Gateway) is the building's reception desk: everyone from outside arrives at one street address, and reception routes them by name — "third floor for Accounts, second for Sales" — based on the hostname and path they asked for.

The single most useful fact: **a Service is not a process.** There is no proxy server sitting at the Service IP. kube-proxy programmes iptables or IPVS rules on every node so that packets sent to the Service's virtual IP are DNAT'd to one of the backing pod IPs. The ClusterIP exists only as a rule in the kernel's packet-mangling tables — which is why, in iptables mode, you cannot ping it and tcpdump on the Service IP shows nothing. In IPVS mode the IP sits on a dummy interface, so ping may be answered locally, but TCP/UDP to the Service port still works only through DNAT.

The second most useful fact: Endpoints are the join. A Service selects pods by label; the endpoints controller writes the list of ready pod IPs into an EndpointSlice. If that list is empty, the Service blackholes traffic no matter how correct everything else looks. Ninety percent of "the Service isn't working" is an empty EndpointSlice.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision