Services and endpoints
- Service YAML, EndpointSlice updates across nodes, cross-node packet routing, DNS and existing connections.
Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.
- A Service selects Pods by label. An EndpointSlice lists their addresses, ports and readiness. With the ordinary readiness policy shown, a kubelet’s Pod status update leads the controller to publish a changed endpoint condition.
- Nodes A and B each apply that update to their Service routing rules. One node can still select the old destination for a new connection while the other has withdrawn it. Existing connections have their own lifetime.
Reading
Services and endpoint eligibility
Services and endpoint eligibility
Kubernetes 1.35.0 source · Linux iptables walkthrough
Start with a Service and its Pods
The example exposes atlas-web:80 inside the chosen namespace and sends traffic to port 8080 on matching Pods. Replace the placeholder image with an application that implements /ready; the manifest uses illustrative names and addresses.
The Service selector matches Pod labels in the same namespace, not the Deployment object. port is the Service-facing port; targetPort: http resolves the named container port. Declaring containerPort does not start a listener. Two replicas also do not guarantee two different nodes.
Deployment and Service — named backend port and readinessyaml
# Learning manifest. Use an existing chosen namespace for both objects.
# Replace this placeholder with an image that listens on 8080 and serves /ready.
# Replica count does not guarantee placement on different nodes.
apiVersion: apps/v1
kind: Deployment
metadata:
name: atlas-web
spec:
replicas: 2
selector:
matchLabels:
app: atlas-web
template:
metadata:
labels:
app: atlas-web
spec:
containers:
- name: web
image: registry.example.com/team/web:REPLACE_ME
ports:
- name: http
containerPort: 8080
readinessProbe:
httpGet:
path: /ready
port: http
periodSeconds: 5
failureThreshold: 2
---
apiVersion: v1
kind: Service
metadata:
name: atlas-web
spec:
type: ClusterIP
selector:
app: atlas-web
ports:
- name: http
port: 80
targetPort: http
What Kubernetes creates for you
For an ordinary selector-based Service, the control plane allocates a ClusterIP and the EndpointSlice controller maintains backend records. You do not configure a separate endpoint list on every node. Omitting type still defaults to ClusterIP.
An endpoint is a destination such as PodIP:8080. An EndpointSlice is an API object grouping destinations, ports, node information and conditions. A Service can have several slices; consumers combine them. The slice is data, not a proxy through which a request passes.
Illustrative controller-generated excerpt, not a manifest to apply:
ports:
- name: http
port: 8080
protocol: TCP
endpoints:
- addresses: ["10.244.2.17"]
nodeName: worker-b
conditions:
ready: true
serving: true
terminating: false
How readiness reaches the other nodes
Suppose the Pod on worker-b becomes unready. This is an asynchronous control-plane sequence:
- Worker-b’s kubelet runs the readiness probe. After its failure threshold, it updates container readiness and the resulting Pod Ready condition.
- Kubelet publishes changed Pod status to the API server. Other nodes do not discover that change by probing this Pod themselves.
- The EndpointSlice controller observes the change, reconciles matching Services and writes the updated endpoint conditions through the API. An unready address can remain in the slice with
ready: false; its absence is not the only sign of withdrawal. - Each kube-proxy observes Service and EndpointSlice updates and reconciles forwarding state on its own node. Linux implementations commonly install kernel rules rather than proxying every packet in userspace.
The API server distributes desired/observed state. Application traffic does not traverse it.
Follow one connection across two nodes
Take a client Pod on worker-a, Service IP 10.96.0.20:80, and a selected backend 10.244.2.17:8080 on worker-b. These addresses and placements are illustrative. This walkthrough uses Linux kube-proxy iptables mode, ordinary Cluster traffic policy and no session affinity.
- Cluster DNS resolves
atlas-webto the Service ClusterIP. - For a new TCP connection, worker-a’s programmed Service rules select an eligible backend and translate the destination to
10.244.2.17:8080. Default iptables selection is probabilistic, not a round-robin promise. - The Pod network delivers packets to worker-b and then to the destination Pod. Service backend selection and cross-node Pod reachability are separate jobs.
- Connection tracking retains the NAT mapping for that flow and applies the reverse translation to replies. The client continues to address the Service.
The networking implementation decides whether cross-node delivery uses an overlay, native routes or another mechanism. A Service alone does not install a universal tunnel between nodes.
Why a readiness change is not an instant drain
Probe detection, status publication, controller reconciliation, API watch delivery and local rule updates take separate amounts of time. Nodes can temporarily use different backend sets. There is no universal “all nodes update after five seconds” guarantee; the probe period is only one input.
In the iptables example, an established TCP connection is not migrated when its backend becomes unready. HTTP keep-alive and HTTP/2 can carry additional requests on that same connection while the Pod remains reachable. A Pod exit or network failure can break it. Readiness changes future selection; graceful shutdown must also handle accepted work and connection lifetime.
Without a readiness probe, Kubernetes has no such application-level check to run. Container readiness can become true once it is running, subject to startup state and any Pod readiness gates. The Service does not invent a health endpoint. See the separate lifecycle-probes guide for startup gating and overlapping initial delays.
DNS and policies that change this example
DNS: a normal Service resolves to its ClusterIP; DNS does not choose a Pod for each HTTP request. With clusterIP: None, a headless Service has no VIP forwarding and DNS can return endpoint addresses for the client to choose. Client discovery and caching then matter.
Local policies: internalTrafficPolicy: Local restricts internal selection to eligible backends on the client’s node. If none exist there, remote ready Pods do not provide fallback. externalTrafficPolicy: Local concerns externally arriving Service traffic and local backends; it is a separate control.
Readiness exceptions: publishNotReadyAddresses: true makes endpoints appear ready for discovery/selection even when their Pods are not ready. During termination, serving and terminating also carry information used by draining-aware consumers; eligible serving/terminating fallbacks can exist. Do not infer that every terminating Pod is immediately unreachable.
Other dataplanes: an eBPF implementation can replace kube-proxy and choose the backend at a different interception point, including socket connect. A service mesh adds its own discovery and connection behavior. Keep the state-propagation model, but check the actual dataplane before assuming the iptables packet path.
Inspect each stage independently
For a selected context and existing namespace, compare Pod readiness with the Service selector and all its slices. Substitute CONTEXT and NAMESPACE; these are read-only examples and have not been run against your cluster:
kubectl --context CONTEXT -n NAMESPACE get pods -l app=atlas-web -o wide
kubectl --context CONTEXT -n NAMESPACE get service atlas-web -o yaml
kubectl --context CONTEXT -n NAMESPACE get endpointslices -l kubernetes.io/service-name=atlas-web -o yaml
Correct EndpointSlices prove published API state, not convergence on every node. If a particular client still reaches an old backend, inspect that client node’s proxy/dataplane state and distinguish a reused connection from a genuinely new TCP connection. This is why one successful curl or one slice snapshot cannot prove cluster-wide propagation.