Service Topology:
1. Service Topology enables a service to route traffic based upon the Node topology of the cluster.
For example, a service can specify that traffic be preferentially routed to endpoints that are on the same
Node as the client, or in the same availability zone.
2.
By default, traffic sent to a ClusterIP or NodePort Service may be routed to any backend address for the
Service or in other words by default traffic can goes on any node.
3.
But Kubernetes 1.7 made it possible to route "external" traffic to the Pods running on the same Node that
received the traffic or same region or zone.
4.
If your cluster has the Service Topology feature gate enabled, you can control Service traffic routing by
specifying the topologyKeys field on the Service spec.
5.
6. If topologyKeys is not specified or empty, no topology constraints will be applied.
Consider a cluster with Nodes that are labeled with their hostname, zone name, and region name. Then you
can set the topologyKeys values of a service to direct traffic as follows.
7.
Examples
The following are common examples of using the Service Topology feature.
1. Only Node Local Endpoints
A Service that only routes to node local endpoints. If no endpoints exist on the node, traffic is
dropped: