Kubernetes on networking
Every Pod gets its own IP address
- Any Pod can reach any other Pod directly, on any node, without address translation.
- A network plugin (CNI plugin), such as Cilium or Calico, makes this work.
- A new Pod gets a new IP, so never hard-code Pod IPs.
A Service is a stable address for a set of Pods
- It selects Pods by label, such as app=web, and spreads traffic across the ready ones.
- It gets a fixed virtual IP and a DNS name: web.shop.svc.cluster.local.
- Inside the shop namespace the short name works: http://web.
The Service type decides who can reach it
- ClusterIP is the default, and is right for traffic between your own apps.
- LoadBalancer asks your cloud for an external load balancer for that one Service.
- A headless Service has no virtual IP. Its DNS name returns the Pod IPs themselves.
| Type | Reachable from | How |
|---|---|---|
| ClusterIP (default) | Inside the cluster | A virtual IP |
| NodePort | Outside, through any node | A port from 30000 to 32767 on each node |
| LoadBalancer | Outside, through a cloud address | An external load balancer |
| Headless (clusterIP: None) | Inside the cluster | DNS returns each Pod IP |
Gateway API routes outside traffic to Services
- One load balancer per Service adds up. Share one entry point and route by host and path.
- A Gateway is that entry point: a listener, such as HTTP on port 80.
- An HTTPRoute sends matching requests, such as shop.example.com/cart, to a Service.
- Gateway API is an add-on. You install its resource types and a controller that runs it.
- Clientshop.example.com/cart
- Gatewaylistens on a port
- HTTPRoutematches host and path
- Servicestable virtual IP
- Podone of the ready ones
Ingress still works, but it is frozen
- Ingress is the older API for the same job. It is stable and will not be removed.
- It gets no new features. The Kubernetes project recommends Gateway API instead.
- The widely used ingress-nginx controller was retired in March 2026, with no more fixes.
- If you still run ingress-nginx, move to Gateway API or to a maintained Ingress controller.
NetworkPolicy is the firewall between Pods
- By default, every Pod accepts connections from every other Pod.
- A NetworkPolicy selects Pods by label and lists who may connect in or out.
- Start each namespace with a deny-all policy, then allow only what is needed.
- Policies only work if the network plugin enforces them. If not, they do nothing.