Services and endpoints

  • Service YAML, EndpointSlice updates across nodes, cross-node packet routing, DNS and existing connections.
100%
1 Kubelet2 API server + EndpointSlice controller3 Each nodewatches / syncsNew connections follow each node’s current rules. Existing connections can continue.Ready adds a backend; Unready withdraws it after propagationHealth checksControl / stateFailure / rejectionsuccess thresholdcontroller reconcilescontrolcontrolfailure thresholdcontroller reconcilescontrolcontrolAfter the configured success threshold, readiness can recover. The local probe loop keeps running while the Pod is unready. This example assumes the other Pod readiness conditions are satisfied. Additional containers and readiness gates can keep the whole Pod unready.Readiness succeedsKubelet publishes the Pod condition through the API server. The update is control-plane state, not a request forwarded through the API server. The two rows show alternative states of the same Pod, not two Pods in series.Pod ReadyTrueThe EndpointSlice controller watches relevant Pod and Service changes and reconciles the endpoint conditions in the API server. A ready endpoint can be eligible for new Service connections after a node consumes the update. This example uses a normal selector-based Service, a non-terminating Pod and publishNotReadyAddresses=false.EndpointSliceready: trueThe service-routing agent on this node watches Service and EndpointSlice state and updates its local forwarding data plane. After this node applies the update, new Service connections can select the Pod. Node A and Node B update independently. There is no atomic cluster-wide switch and no guaranteed fixed propagation time. Existing connection tracking and keep-alive connections can continue reaching the previous Pod; readiness does not migrate or cancel them.Node Ainclude PodThe service-routing agent on this node watches Service and EndpointSlice state and updates its local forwarding data plane. After this node applies the update, new Service connections can select the Pod. Node A and Node B update independently. There is no atomic cluster-wide switch and no guaranteed fixed propagation time. Existing connection tracking and keep-alive connections can continue reaching the previous Pod; readiness does not migrate or cancel them.Node Binclude PodAfter the configured failure threshold, readiness becomes false. A readiness failure does not restart the container. This example assumes the other Pod readiness conditions are satisfied. Additional containers and readiness gates can keep the whole Pod unready.Readiness failsKubelet publishes the Pod condition through the API server. The update is control-plane state, not a request forwarded through the API server. The two rows show alternative states of the same Pod, not two Pods in series.Pod ReadyFalseThe EndpointSlice controller watches relevant Pod and Service changes and reconciles the endpoint conditions in the API server. The Pod address may remain in the EndpointSlice with ready: false. Consumers normally exclude that endpoint from new Service connections. This example uses a normal selector-based Service, a non-terminating Pod and publishNotReadyAddresses=false.EndpointSliceready: falseThe service-routing agent on this node watches Service and EndpointSlice state and updates its local forwarding data plane. After this node applies the update, new Service connections select another eligible Pod. With no eligible backends, the connection cannot reach a ready target. Node A and Node B update independently. There is no atomic cluster-wide switch and no guaranteed fixed propagation time. Existing connection tracking and keep-alive connections can continue reaching the previous Pod; readiness does not migrate or cancel them.Node Aexclude PodThe service-routing agent on this node watches Service and EndpointSlice state and updates its local forwarding data plane. After this node applies the update, new Service connections select another eligible Pod. With no eligible backends, the connection cannot reach a ready target. Node A and Node B update independently. There is no atomic cluster-wide switch and no guaranteed fixed propagation time. Existing connection tracking and keep-alive connections can continue reaching the previous Pod; readiness does not migrate or cancel them.Node Bexclude Podsuccess thresholdcontroller reconcilesfailure thresholdcontroller reconciles

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.
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:

  1. Worker-b’s kubelet runs the readiness probe. After its failure threshold, it updates container readiness and the resulting Pod Ready condition.
  2. Kubelet publishes changed Pod status to the API server. Other nodes do not discover that change by probing this Pod themselves.
  3. 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.
  4. 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.

  1. Cluster DNS resolves atlas-web to the Service ClusterIP.
  2. 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.
  3. 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.
  4. 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.