<p>I am new to Kubernetes and currently deploy an application on AWS EKS.</p>
<p>I want to configure a <code>Service</code> of my K8s cluster deployed on AWS EKS.</p>
<p>Here is the description of my issue: I did an experiment. I spin up <strong>2</strong> Pods running the same web application and expose them using a service (the Service is using <code>LoadBalancer</code> type). Then I got an external IP of that Service. Then and found that requests that I sent were not distributed evenly to every <code>Pod</code> under the <code>Service</code> I created. To be more precise, I sent <strong>3</strong> requests and all the three requests are processed by <strong>the same Pod</strong>.</p>
<p>Therefore, I want to configure the load balancer algorithm to be <code>round robin</code> or <code>least_connection</code> to resolve this issue.</p>
<p>I asked a similar question before and I am suggested to try the IPVS mode of the <code>kube-proxy</code>, but I did not get the detailed instruction on how to apply that config, and did not find any useful material online. If the IPVS mode is a feasible solution to this issue, please provide some detailed instructions.</p>
<p>Thanks!</p>

Xiao Ma
<p>Had the exact issues and while using the <code>-H &quot;Connection: close&quot;</code> tag when testing externally load balanced connections helps, I still wanted inter-service communication to benefit from having IPVS with <code>rr</code> or <code>sed</code>.</p>
<p>To summarize, you will need to setup the following dependencies to the nodes. I would suggest adding these to your cloud config.</p>
<pre><code>#!/bin/bash
sudo yum install -y ipvsadm
sudo ipvsadm -lsudo modprobe ip_vs 
sudo modprobe ip_vs_rr
sudo modprobe ip_vs_wrr 
sudo modprobe ip_vs_sh
sudo modprobe nf_conntrack_ipv4
</code></pre>
<p>Once that is done will need to edit your <code>kube-proxy-config</code> in <code>kube-system</code> namespace to have <code>mode: ipvs</code> and <code>scheduler: &lt;desired lb algo&gt;</code>.</p>
<p>Lastly, you will need to update the container commands for the <code>kube-proxy</code> daemonset with the appropriate proxy-mode flag <code>--proxy-mode=ipvs</code> and <code>--ipvs-scheduler=&lt;desired lb algo&gt;</code>.</p>
<p>Following are the available lb algos for IPVS:</p>
<pre><code>rr: round-robin
lc: least connection
dh: destination hashing
sh: source hashing
sed: shortest expected delay
nq: never queue
</code></pre>
<p>Source: <a href="https://medium.com/@selfieblue/how-to-enable-ipvs-mode-on-aws-eks-7159ec676965" rel="nofollow noreferrer">https://medium.com/@selfieblue/how-to-enable-ipvs-mode-on-aws-eks-7159ec676965</a></p>
