<p>I was asked about it, and I couldn't find info about it online - Which algorithm Kubernetes uses to nevigate traffics in replicaset or deployment (I guess that they the same) for pods? </p>

<p>Lets say, I have replica of 5 pods in my Kubernetes cluster, defined in replicaset. How does the cluster pick which pod to go to, in new request? Is it uses round-robin? I couldn't find info about it.</p>

<p>The algorithm applied to determine which pod will process the request depends on <strong><em>kube-proxy</em></strong> mode that is running.</p>

<ul>
<li><p>In 1.0, the proxy works in mode called userspace and default algorithm is round robin.</p></li>
<li><p>In 1.2 mode iptables proxy was added, but still round robin is used due to iptables limitations.</p></li>
<li><p>In 1.8.0-beta, IP Virtual Server (IPVS) was introduced, it allow much more algorithms options, like:</p>

<ul>
<li>RoundRobin;</li>
<li>WeightedRoundRobin;</li>
<li>LeastConnection;</li>
<li>WeightedLeastConnection;</li>
<li>LocalityBasedLeastConnection;</li>
<li>LocalityBasedLeastConnectionWithReplication;</li>
<li>SourceHashing;</li>
<li>DestinationHashing;</li>
<li>ShortestExpectedDelay;</li>
<li>NeverQueue.</li>
</ul></li>
</ul>

<p>References:</p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies</a>
<a href="https://sookocheff.com/post/kubernetes/understanding-kubernetes-networking-model/" rel="nofollow noreferrer">https://sookocheff.com/post/kubernetes/understanding-kubernetes-networking-model/</a></p>
