Services and Networking

Pods are ephemeral and get new IPs every time they're replaced, so how does anything reliably reach them? The Service — a stable address and load balancer in front of an ever-changing set of pods. Kubernetes networking looks intimidating, but it's a few clear layers solving one problem: stable communication over unstable pods.

The pod post established that pods are ephemeral with changing IPs; the controller post showed pods constantly created and replaced. So the obvious question: how do you reliably communicate with pods that keep changing? The answer is the Service — Kubernetes’s stable networking abstraction — plus the networking model underneath. This post covers the cluster network model, Services and their types, service discovery via DNS, and Ingress for external traffic. It’s how stable communication works over unstable pods.

The Kubernetes network model

First, the ground rules of Kubernetes networking, which are simpler than they look:

This is the core networking problem: the flat network lets pods communicate, but pod IPs are unstable, so you need something stable to communicate through. That something is the Service.

Services: a stable address over changing pods

A Service provides a stable network identity (a stable IP and DNS name) in front of a dynamic set of pods, load-balancing traffic across them. It’s the answer to “how do I reliably reach pods that keep changing”:

Service "orders" (stable IP + DNS name)
   → selects pods by label (e.g. app=orders)
   → load-balances traffic across the CURRENT set of matching pods
   → as pods come and go, the Service tracks them; its own address stays stable

The mechanism:

This decouples clients from the ephemeral pods: you talk to orders (stable), and Kubernetes routes to whichever pods currently implement it, load-balanced, self-healing (unhealthy pods drop out). The Service is the stable layer over unstable pods — the direct solution to pod ephemerality (post three). Under the hood, kube-proxy (or equivalent) on each node programs the routing that makes the Service’s virtual IP forward to real pods, but the abstraction you use is simply “a stable name that reaches my pods.”

Service types

Services come in types, for different exposure needs:

The progression ClusterIP → NodePort → LoadBalancer is internal-only → node-exposed → cloud-external. You pick based on who needs to reach the service: internal microservices use ClusterIP; something exposed to the internet uses LoadBalancer (or, more commonly for HTTP, Ingress — below).

Service discovery via DNS

How do pods find Services? DNS. Kubernetes runs an internal DNS service, and every Service automatically gets a DNS name, so pods reach a Service by name rather than IP:

A pod can reach the "orders" Service in namespace "shop" at:
   orders.shop.svc.cluster.local   (or just "orders" from within the same namespace)

So the full picture of in-cluster communication: a pod uses a Service name (DNS) → resolves to the Service’s stable IP → the Service load-balances to a healthy backing pod. This is how microservices in Kubernetes reliably talk to each other despite constant pod churn — stable names over stable Service IPs over ephemeral pods, with discovery built in via DNS. This is the DNS-as-service-discovery pattern from the networking series, realized in Kubernetes.

Ingress: HTTP routing from outside

For external HTTP/HTTPS traffic, a LoadBalancer per service is coarse (one external IP per service). Ingress provides smarter external HTTP routing — a single entry point that routes to multiple Services by host and path:

Internet → Ingress (one external entry point)
   route by host/path:
     api.example.com/*       → api Service
     app.example.com/*       → frontend Service
     example.com/images/*    → images Service

So the external-traffic story: Ingress (or a Gateway) is the smart HTTP front door routing by host/path to internal Services, which load-balance to pods. Combined, external users hit the Ingress, get routed to the right Service, and reach a healthy pod — stable, load-balanced, TLS-terminated — over the churning pods beneath.

Networking, demystified

The takeaway: Kubernetes networking is a few layers solving one problem — stable communication over ephemeral pods. The flat network gives every pod an IP and lets pods reach each other, but pod IPs churn, so Services provide a stable address and load balancer over a label-selected, ever-changing set of pods; DNS makes Services discoverable by name (service discovery); Service types (ClusterIP/NodePort/LoadBalancer) control internal vs external exposure; and Ingress provides smart external HTTP routing (host/path, TLS) to Services. Each layer is an answer to “how do I reliably reach things that keep changing,” which is the pod-ephemerality problem from post three. Master this and Kubernetes networking is comprehensible: stable names → stable Service IPs → load-balanced healthy pods. The next post covers giving those pods configuration and persistent state.

Key takeaways

Further reading

Sources & References

Services and networking