<p>I'm trying to set up an ingress controller in Kubernetes that will give me strict alternation between two (or more) pods running in the same service.</p>
<p>My testing setup is a single Kubernetes node, with a deployment of two nginx pods.
The deployment is then exposed with a NodePort service.</p>
<p>I've then deployed an ingress contoller (I've tried both <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">Kubernetes Nginx Ingress Controller</a> and <a href="https://github.com/nginxinc/kubernetes-ingress" rel="nofollow noreferrer">Nginx Kubernetes Ingress Controller</a>, separately) and created an ingress rule for the NodePort service.</p>
<p>I edited index.html on each of the nginx pods, so that one shows &quot;SERVER A&quot; and the other &quot;SERVER B&quot;, and ran a script that then <code>curl</code>s the NodePort service 100 times. It <code>grep</code>s &quot;SERVER x&quot; each time, appends it to an output file, and then tallies the number of each at the end.</p>
<p>As expected, curling the NodePort service itself (which uses kube-proxy), I got completely random results-- anything from 50:50 to 80:20 splits between the pods.</p>
<p>Curling the ingress controller, I consistently get something between 50:50 and 49:51 splits, which is great-- the default round-robin distribution is working well.</p>
<p><strong>However</strong>, looking at the results, I can see that I've curled the same server up to 4 times in a row, but I need to enforce a strict alternation A-B-A-B. I've spent quite a researching this and trying out different options, but I can't find a setting that will do this. Does anyone have any advice, please?</p>
<p>I'd prefer to stick with one of the ingress controllers I've tried, but I'm open to trying a different one, if it will do what I need.</p>

hiiamelliott
<p>Looks like there are 2 versions of ingress controller.</p>
<ol>
<li><p>Which K8S community has been maintaining which is <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx</a></p>
</li>
<li><p>Which Nginx is maintaining(Opensource &amp; Paid): <a href="https://github.com/nginxinc/kubernetes-ingress" rel="nofollow noreferrer">https://github.com/nginxinc/kubernetes-ingress</a></p>
</li>
</ol>
<p>The second one seems to be doing strict round robin(still testing) after adding <code>nginx.org/lb-method: “round_robin”</code> while the first one does 50:50 aggregate load balancing between replica's</p>
<p>In my opinion its an important difference but with lot of confusion with names, difference between them can be read <a href="https://www.nginx.com/blog/guide-to-choosing-ingress-controller-part-4-nginx-ingress-controller-options/" rel="nofollow noreferrer">here</a></p>
<p>I composed this answer with help of comments from @hiiamelliott...</p>
