<p>I am new to microservices. I have few apps to deploy as microservices.</p>
<p>I need a API and Load balancer. For API gateway I come to know about Ingress Nginx. But I am not sure hot setup load balancing. However I could configure it for API gateway as below.</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
spec:
  rules:
    - host: example.dev
      http:
        paths:
          - path: /api/users/?(.*)
            backend:
              serviceName: auth-srv
              servicePort: 3000
          - path: /api/orders/?(.*)
            backend:
              serviceName: order-srv
              servicePort: 3000
          - path: /?(.*)
            backend:
              serviceName: client-srv
              servicePort: 3000
</code></pre>
<p>I also have one confusion:
<a href="https://i.stack.imgur.com/6S45q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6S45q.png" alt="enter image description here" /></a></p>
<p>Load balancer sits before API Gateway i.e nginx controller,</p>
<p>How would it I configure Ingress-Nginx for load balancing?</p>
<p>Because load balancer will redirect request to nginx controller</p>
<p>So, <code>Load balancer -&gt; API Gateway &gt; /api/orders</code></p>
<p>Now, <code>/api/orders -&gt; order-srv -&gt; pods</code></p>
<p>Clearly Load balancer should decide to which pod it should route the request?</p>
<p>How can I achieve that?</p>

confusedWarrior
<p>Well, this is something like -</p>
<p>You got a request from external world and that has been at first level intercepted at load balancer layer and API Gateway should be one of the Microservices where you will keep all of the URL mappings say - <code>/api/orders/{orderId}</code> brings this to your API Gateway and in that API Gateway you can have a logic to redirect this to some order service behind the scenes via <code>Fully Qualified Domain Name of order service (FQDN) :portNumber/{uri}</code></p>
<p>So its good idea to simply route traffic to frontend and API Gateway via your ingress rules , i.e.</p>
<p><code>- path: /?(.*)</code>  will take it to client service or frontend</p>
<p><code>- path: /api/?(.*)</code> this shall take it to API Gateway service which has routing map to all of the services appearing behind the scenes</p>
