liveBook · Manning

Internal traffic policy

As explained in Kubernetes in Action, Second Edition

Internal traffic policy is a Kubernetes Service setting that restricts traffic from a client pod to service endpoints on the same node when configured for Local routing.

Internal traffic policy controls where traffic from a client pod may reach a Service endpoint. With Local routing, each client pod connects only to matching endpoints on its own node; if none exist there, the connection fails. This suits node-bound agents or devices, where crossing to another node would reach the wrong resource. section 11.5.1

Create a Service with Local routing

Apply a Service whose selector finds quote pods but whose routing remains node-local: apiVersion: v1 kind: Service metadata: name: quote-local spec: internalTrafficPolicy: Local selector: app: quote ports: - name: http port: 80 targetPort: 80 protocol: TCP Run repeated requests from a client pod with kubectl exec. Responses come only from quote pods on the client’s node. Moving the client to a node without a local endpoint causes the request to fail.

Use Local routing when the endpoint is tied to the client’s node:

  • Expose one per-node agent through a stable Service rather than requiring clients to discover node IP addresses. section 17.3.3
  • Treat the Service as a set of per-node Services: clients on node A use only endpoints on node A, and likewise for node B. section 17.3.3
  • Check node coverage before relying on the Service; a node without an agent endpoint returns a failed connection. section 17.3.3

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains manifest configuration, request behavior, per-node semantics, and missing-endpoint failures without detailing networking internals.
Examples
Demonstrates quote-local requests, a node-agent Service, and Kiada configuration through kubectl commands and YAML manifests.
What it assumes
Assumes familiarity with pods and Services while demonstrating selectors, endpoints, kubectl exec, and DaemonSet locality.
What you can do after
Operate/configure it by applying a Local Service and verifying that client requests reach only same-node endpoints.
How it connects
Connects Kubernetes Services with service endpoints, DaemonSets, node selectors, and external traffic policy.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.