<p>I understand what a Cluster IP service is and everything, I just don't understand the 'behind the scenes' and routing. Can someone PLEASE explain it to me!</p>
<ol>
<li><p>A request is made to the Cluster IP service. If this service is serving multiple pods, how does the service choose which pod to send the request to, what is controlling and deciding that?</p>
</li>
<li><p>Once a pod is chosen and the request is sent to it are there iptables (added by kube-proxy) within that pod mapping the service to its corresponding pods and the pod then forwards/load-balances that request off again? unless it's that pods turn to process the request?</p>
</li>
</ol>
<p>Thank you so much</p>

jssteele89
<p>Please find your answers below.</p>
<ol>
<li><p>By default kubernetes algorithm decide based on round robin routing, but if you want you can use specific algorithm to route the traffic but that is only possible if proxy is running in IPVS mode or you can use session affinity, if you want to transfer the traffic to specific pod based on user cookie or something else.</p>
</li>
<li><p>Partially yes, usually kubernetes follow labeling concept for determining the pod and then based on that it will route the request, so it will mainly work based on dns based pod ip resolution mechanism. But if it is egress traffic then kubernetes usage iptables to handle the same.</p>
</li>
</ol>
<p>For more details read these two blogs.</p>
<ul>
<li><a href="https://dustinspecker.com/posts/iptables-how-kubernetes-services-direct-traffic-to-pods/#add-a-virtual-ip-in-iptables" rel="nofollow noreferrer">https://dustinspecker.com/posts/iptables-how-kubernetes-services-direct-traffic-to-pods/#add-a-virtual-ip-in-iptables</a></li>
<li><a href="https://technekey.com/changing-the-traffic-distribution-of-a-kubernetes-service/" rel="nofollow noreferrer">https://technekey.com/changing-the-traffic-distribution-of-a-kubernetes-service/</a></li>
</ul>
<p>Hope this give you more detailed idea. Thanks!!</p>
