content/en/docs/ambient/usage/traffic-distribution/index.md
The networking.istio.io/traffic-distribution annotation controls how {{< gloss >}}ztunnel{{< /gloss >}} distributes traffic across available endpoints. This is useful for keeping traffic local to reduce latency and cross-zone costs.
| Value | Behavior |
|---|---|
PreferSameZone | Prioritize endpoints by proximity: network, region, zone, then subzone. Traffic goes to the closest healthy endpoints first. |
PreferClose | Deprecated alias for PreferSameZone. See Kubernetes enhancement proposal 3015. |
PreferSameNode | Prefer endpoints on the same node as the client. |
| (unset) | No locality preference. Traffic is distributed across all healthy endpoints. |
The annotation can be applied to:
Service: Affects traffic to that specific serviceNamespace: Sets the default for all services in the namespaceServiceEntry: Affects traffic to external servicesWhen multiple levels are configured, the most specific wins:
spec.trafficDistribution field (Service only)Service/ServiceEntryNamespaceApply to a single service:
{{< text yaml >}} apiVersion: v1 kind: Service metadata: name: my-service annotations: networking.istio.io/traffic-distribution: PreferSameZone spec: selector: app: my-app ports:
Apply to all services in a namespace:
{{< text yaml >}} apiVersion: v1 kind: Namespace metadata: name: my-namespace annotations: networking.istio.io/traffic-distribution: PreferSameZone {{< /text >}}
Services in the namespace inherit this setting unless they have their own annotation.
A service can override the namespace setting with its own annotation:
apiVersion: v1 kind: Service metadata: name: different-service namespace: my-namespace annotations: networking.istio.io/traffic-distribution: PreferSameNode spec: selector: app: different-app ports:
Services without an annotation inherit the namespace setting.
PreferSameZoneWith PreferSameZone, ztunnel categorizes endpoints by locality and routes to the closest healthy ones:
If all endpoints in a closer locality become unhealthy, traffic automatically fails over to the next level.
For example, a service with endpoints in zones us-west, us-west, and us-east:
us-west sends all traffic to the two us-west endpointsus-west endpoint fails, traffic goes to the remaining us-west endpointus-west endpoints fail, traffic fails over to us-eastPreferSameNodeWith PreferSameNode, ztunnel prefers endpoints running on the same Kubernetes node as the client. This minimizes network hops and latency for node-local communication.
trafficDistributionKubernetes 1.31 introduced the spec.trafficDistribution field on Services. This Istio annotation provides the same functionality with additional benefits:
spec.trafficDistribution | Annotation | |
|---|---|---|
| Kubernetes version | 1.31+ | Any |
Service | Yes | Yes |
ServiceEntry | No | Yes |
Namespace | No | Yes |
When both the spec field and annotation are set on a Service, the spec field takes precedence.
Waypoints automatically configure this annotation.