Updated on 2025-06-13 GMT+08:00

Service Affinity

It denotes if a Service desires to route external traffic to node-local or cluster-wide endpoints. Two options are available: Cluster (default) and Local.

  • Cluster level service affinity: Traffic can be forwarded properly to all the nodes in a cluster. Service access will impact performance due to route redirections. This service affinity obscures the client source IP address and may cause a second hop to another node, but should have good overall load-spreading.
  • Node level service affinity: Traffic can be forwarded to the node where the pods associated with the Service are running. Service access will not impact performance due to route redirections. This service affinity preserves the client source IP address and avoids a second hop for the LoadBalancer and NodePort Services, but risks potentially imbalanced traffic spreading.

Value Range

Cluster or Local

Default Value

Cluster

Modifiable

Yes

Scope

CCE standard and CCE Turbo clusters

Suggestions

To enable preservation of the client IP, set externalTrafficPolicy to Local. By default, the source IP address seen in the target container is not the original source IP address of the client. Select a dedicated load balancer to retain the client IP address.

The source IP address of the client cannot be retained for a shared load balancer.