kubernetes nodeport service load balancing Let's assume I have three node named n1, n2, n3. created four pods named p1, p2, p3, p4, k8s scheduler placed pods in nodes as follows
n1 -&gt; p1
n2 -&gt; p2
n3 -&gt; p3, p4
Now, to access these pods I have created a nodeport service. Nodeport service will open same numbered ports in each nodes. Nodes will have iptables configured to forward traffics from service to pods.
Let's also assume that I will have a NLB configured top of it. how traffic will be distributed? is it like below?
p1 -&gt; 33.3330%
p2 -&gt; 33.3330%
p3 -&gt; 16.6665%
p4 -&gt; 16.6665%
service is a cluster-wide object. In each node, kube-proxy will create iptable load balancing entry with all available pod's IP based on selector for a service. So NLB will distributed traffic evenly among all nodes. Then each will loadbalance the traffic to all available pods using round robin algorithm.
We will have those traffic distributed among all pods like below.
p1 -&gt; 33.3330%
p2 -&gt; 33.3330%
p3 -&gt; 16.6665%
p4 -&gt; 16.6665%
This will deviate a little bit.