<p>I have two PODS, Server POD, and Client POD. 
My deployment uses replicas more than one.
And using the POD affinity I made to co-locate pair of Client and Server nodes on the same node.</p>

<p>My question is whether the traffic from Client is routed to Server POD on the same node? 
If not, how to configure to achieve the same node routing?</p>

<p>Thanks</p>

Chandu
<p>Pod affinity ensures colocated pods are deployed onto same node. It does not guarantee traffic will be sent to pods on the same node.</p>

<p>You need to use <a href="https://kubernetes.io/docs/concepts/services-networking/service-topology/" rel="nofollow noreferrer">service topology</a>. Kubernetes version 1.17 or later is needed for this feature and you need to <a href="https://kubernetes.io/docs/tasks/administer-cluster/enabling-service-topology/" rel="nofollow noreferrer">enable</a> this feature via feature flag.</p>

<blockquote>
  <p>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</p>
</blockquote>

<p>Consider a cluster with Nodes that are labeled with their <code>hostname</code>, <code>zone name</code>, and <code>region name</code>. Then you can set the <code>topologyKeys</code> values of a service to direct traffic as follows.</p>

<ol>
<li><p>Only to <code>endpoints</code> on the same node, failing if no endpoint exists on the node: <code>["kubernetes.io/hostname"]</code>.</p></li>
<li><p>Preferentially to <code>endpoints</code> on the same node, falling back to <code>endpoints</code> in the same zone, followed by the same region, and failing otherwise: <code>["kubernetes.io/hostname"</code>, <code>"topology.kubernetes.io/zone"</code>, <code>"topology.kubernetes.io/region"]</code>. This may be useful, for example, in cases where data locality is critical.</p></li>
<li><p>Preferentially to the same <code>zone</code>, but fallback on any available <code>endpoint</code> if none are available within this <code>zone</code>: <code>["topology.kubernetes.io/zone", "*"]</code>.</p></li>
</ol>
