<p>I want to implement a simple Layer 7 Load Balancer in my kubernetes cluster which will allow me to expose kubernetes services to external consumers.</p>

<p>I will create a simple ha-proxy based container which will observe kubernetes services and respective endpoints and reload its backend/frontend configuration (complemented with SYN eating rule during reload)</p>

<p>This will allow me to access kubernetes services like SVCa, SVCb, SVCc over</p>

<pre><code>http://load-balancer-ip:port/SVCa -------&gt; Pod endpoints.....
http://load-balancer-ip:port/SVCb -------&gt; Pod endpoints..... 
http://load-balancer-ip:port/SVCc -------&gt; Pod endpoints.....
</code></pre>

<p>How would above approach work compared to </p>

<p>(1) ha-proxy forwarding all the requests to clusterIP address of kubernetes services.</p>

<pre><code> http://load-balancer-ip:port/SVCa -------&gt;clusterIP-SVCa
 http://load-balancer-ip:port/SVCb -------&gt;clusterIP-SVCa
 http://load-balancer-ip:port/SVCc -------&gt;clusterIP-SVCa
</code></pre>

<p>(2) ha-proxy load-balancing requests to worker-node-ip:port obtained by creating NodePort type services</p>

<pre><code>http://load-balancer-ip:port/SVCa  --------&gt; node1:p1, node2:p1, node3:p1
http://load-balancer-ip:port/SVCb  --------&gt; node1:p2, node2:p2, node3:p2
http://load-balancer-ip:port/SVCc  --------&gt; node1:p3, node2:p3, node3:p3
</code></pre>

<p>Note: My k8s cluster is running on custom solution (on-premise VMs) </p>

<p>I think a nginx IngressController can work better in this case.
You only have to set the backend service and the hostname inside the ingress definition.</p>

<p>Take a look here:
<a href="https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx" rel="nofollow">https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx</a></p>
