Pod networks and service routing
Trace a direct Pod connection across nodes and a Service connection through an eligible backend.
What you will understand
- Describe what CNI plugins configure when a Pod joins the network.
- Follow Pod-to-Pod routing and identify where an implementation may use routing or encapsulation.
- Explain how kube-proxy or an alternative implementation uses Service and EndpointSlice information.
Builds on: Topology and resource governance
How Pods communicate across nodes
A frontend Pod on one node opens a connection to an API Pod on another. First the Pods need working interfaces and addresses. Then the network needs a route for the packets. A Container Network Interface (CNI) plugin follows an interface used by runtimes to configure container networking. In a Kubernetes cluster, the network implementation commonly uses plugins to give Pods addresses and connect them to the node’s network, and may run agents to arrange routes and policy across nodes.
From the frontend’s point of view, the direct connection is addressed to the API Pod’s IP. The packet leaves the frontend’s network namespace and travels through the network to the backend. One implementation might route the Pod IP ranges directly. Another might wrap the packet for transport between nodes and unwrap it on arrival. The Pod-path scene focuses on the visible hops, which you can use to ask where a packet could be lost.
Follow traffic between Pods on different nodes
Each Pod has an address of its own. The node network carries traffic between those addresses.
- Container runtimeSet up Pod networkingCNI pluginThe Pod receives a network interface and an IP address.
- Client PodOpen a connection to the backend Pod IPSource nodeThe packet enters the node network with the backend address.
- Source nodeRoute across the worker boundaryDestination nodeThe cluster networking implementation delivers the packet to the worker that hosts the backend.
- Destination nodeDeliver to the application portBackend PodThe application can handle the connection.
Each Pod has an address of its own. The node network carries traffic between those addresses.
CNI providers implement this contract differently; arrows do not prescribe an overlay or particular kernel hook.
Explore another case
How a Service forwards a connection
A Service gives the frontend a stable IP and port as the backend Pods come and go. In the manifest, clients connect to port 80 and the service data plane forwards to port 8080 on a selected backend. Pods must already exist with app: api, and their app must listen on 8080. EndpointSlices identify the current addresses and include readiness conditions. A backend can still appear in a slice when it is unready.
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
ports:
- name: http
port: 80 # Client's Service port.
targetPort: 8080 # Port the selected backend actually listens on.kube-proxy watches Services and EndpointSlices and programs forwarding rules on nodes. The packet path typically goes through the rules it installs. Some CNI implementations replace kube-proxy and use eBPF, which runs programs at kernel hooks, to handle Service forwarding. The details differ by cluster, but in both cases a client that contacts the Service address needs a route to a usable endpoint. Follow the paths in the second scene.
Track the virtual IP and the selected Pod IP
EndpointSlices inform the forwarding implementation. The client sends traffic to the virtual Service address and the node forwards it to a usable backend.
- EndpointSlice controllerPublish matching backend addressesEndpointSliceThe slice records endpoint addresses, ports, and conditions.
- Node networking implementationWatch the Service and backend stateForwarding rulesThe virtual frontend has ready backends to use.
- Client PodConnect to the Service portNode forwardingThe destination starts as the Service IP and port.
- Node forwardingSend traffic to a ready endpointBackend PodThe selected Pod receives the connection on its target port.
EndpointSlices inform the forwarding implementation. The client sends traffic to the virtual Service address and the node forwards it to a usable backend.
Ordinary selector Service without publishNotReadyAddresses; all-unready variant is non-terminating; existing connections are not modeled.
Inspect YAML or commands
Choose a ready backend
kubectl get endpointslices -l kubernetes.io/service-name=api -o yamlExplore another case
Compare direct and Service requests
From your test client, check DNS first. Then compare the selected Pod and EndpointSlice addresses, ports, and conditions. Try the request via the Service and, where policy allows, directly to a known ready Pod’s IP and listening port. A working Pod IP with a failing Service narrows the investigation toward selector, endpoint conditions, or Service forwarding. The example names assume you created api and client. Use the exercise’s actual names and port in the networking lab.
kubectl get service api -o wide
kubectl get pods -l app=api -o wide
kubectl get endpointslices -l kubernetes.io/service-name=api -o yaml
# These example names require matching api and client resources.
# The downloadable baseline instead uses m08 and m08-client, port 80.
kubectl exec client -- nslookup api
kubectl exec client -- wget -qO- http://api:80Test across nodes in the target cluster
Two Pods on one node can communicate even if routing between nodes is broken. Repeat the test from another node when investigating cross-node failures. For a connection that reaches the Service with no ready backend, implementations can differ in whether a caller sees a refusal or timeout. Inspect the objects and run a controlled request before inferring the cause from one error string.
Check your understanding
A Service resolves in DNS and you can reach its ready Pod IP directly. The Service request still fails. Where would you look next?
Check the Service port and target port, then the EndpointSlice ready condition and which backend address it publishes. If those are correct, investigate the cluster’s Service forwarding implementation on the caller’s node.
Primary documentation
Go to the source
- Cluster networking
- Virtual IPs and Service proxies
- EndpointSlices
- CNI specification
- Cilium kube-proxy replacement (implementation example)
Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise