<p><strong>What I have:</strong></p>

<p>I have created one <a href="https://kubernetes.io" rel="nofollow noreferrer">Kubernetes</a> cluster using single node <a href="https://rancher.com/" rel="nofollow noreferrer">Rancher</a> 2.0 deployment. which has 3 etcd, control nodes &amp; 2 worker nodes attached to cluster.</p>

<p><strong>What I did:</strong></p>

<p>I deployed one API gateway to this cluster &amp; one express <code>mydemoapi</code> service (no db) with 5 pods on 2 nodes on port 5000, which I don't want to expose publicly. So, I just mapped that service endpoint with service name in API gateway <code>http:\\mydemoapi:5000</code> &amp; it was accessible by gateway public endpoint.</p>

<p><strong>Problem statement:</strong></p>

<p><code>mydemoapi</code> service is served in random fashion, not in round robin, because default setting of <code>kube-proxy</code> is random as per <a href="https://github.com/rancher/rancher" rel="nofollow noreferrer">Rancher</a> documentation <a href="https://rancher.com/load-balancing-in-kubernetes/" rel="nofollow noreferrer">Load balancing in Kubernetes</a></p>

<p><strong>Partial success:</strong></p>

<p>I created one ingress loadbalancer with <code>Keep the existing hostname option</code> in Rancher rules with this URL <code>mydemoapi.&lt;namespace&gt;.153.xx.xx.102.xip.io</code> &amp; attached this service to ingress, it is served in round robin fashion, but having one problem. This service was using <a href="http://xip.io" rel="nofollow noreferrer"><code>xip.io</code></a> with public ip of my worker node &amp; exposed publicly.</p>

<p><strong>Help needed:</strong></p>

<p>I want to map my internal clusterIP service into gateway with internal access, so that it can be served to gateway internally in round robin fashion and hence to gateway public endpoint. I don't want to expose my service publicly without gateway.</p>

Amreesh Tyagi
<p>Not sure which cloud you are running on, but if you are running in something like AWS you can set the following annotation to <code>true</code> on your <code>Service</code> definition:</p>

<pre><code>service.beta.kubernetes.io/aws-load-balancer-internal: "true"
</code></pre>

<p>Other Cloud providers have similar solutions and some don't even have one. In that case, you will have to use a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer"><code>NodePort</code></a> service and redirect an external load balancer such as one with <a href="http://www.haproxy.org/" rel="nofollow noreferrer"><code>haproxy</code></a> or <a href="https://nginx.org/en/" rel="nofollow noreferrer"><code>nginx</code></a> to forward traffic to that <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer"><code>NodePort</code></a></p>

<p>Another option is to not use an <code>Ingress</code> at all if you want to do round robin between your services is to change your <code>kube-proxy</code> configs to use either the old <a href="https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-userspace" rel="nofollow noreferrer">namespace</a> proxy mode or the more enhanced <a href="https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-ipvs" rel="nofollow noreferrer">ipvs</a> proxy mode. </p>
