<p>I have an EKS cluster for which I want :
- 1 Load Balancer per cluster,
- Ingress rules to direct to the right namespace and the right service.</p>

<p>I have been following this guide : <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes" rel="noreferrer">https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes</a></p>

<p>My deployments:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-world
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - name: hello-world
        image: IMAGENAME
        ports:
        - containerPort: 8000
          name: hello-world


---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bleble
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: bleble
  template:
    metadata:
      labels:
        app: bleble
    spec:
      containers:
      - name: bleble
        image: IMAGENAME
        ports:
        - containerPort: 8000
          name: bleble


</code></pre>

<p>the service of those deployments:</p>

<pre><code>
apiVersion: v1
kind: Service
metadata: 
  name: hello-world-svc
spec: 
  ports: 
     -  port: 8080
        protocol: TCP
        targetPort: 8000
  selector: 
    app: hello-world
  type: NodePort

---

apiVersion: v1
kind: Service
metadata: 
  name: bleble-svc
spec: 
  ports: 
     -  port: 8080
        protocol: TCP
        targetPort: 8000
  selector: 
    app: bleble
  type: NodePort

</code></pre>

<p>My Load balancer:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: "true"
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      targetPort: http
</code></pre>

<p>My ingress:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: simple-fanout-example
  namespace : default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: internal-lb.aws.com
    http:
      paths:
      - path: /bleble
        backend:
          serviceName: bleble-svc
          servicePort: 80
      - path: /hello-world
        backend:
          serviceName: hello-world-svc
          servicePort: 80
</code></pre>

<p>I've set up the Nginx Ingress Controller with this : kubectl apply -f <a href="https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.24.1/deploy/mandatory.yaml" rel="noreferrer">https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.24.1/deploy/mandatory.yaml</a></p>

<p>I am unsure why I get a 503 Service Temporarily Unavailable for one service and one 502 for another... I would guess it's a problem of ports or of namespace? In the guide, they don't define namespace for the deployment...</p>

<p>Every resources create correctly, and I think the ingress is actually working but is getting confused where to go. </p>

<p>Thanks for your help!</p>

<p>In general, use <code>externalTrafficPolicy: Cluster</code> instead of <code>Local</code>. You can gain some performance (latency) improvement by using <code>Local</code> but you need to configure those pod allocations with a lot efforts. You will hit 5xx errors with those misconfigurations. In addition, <code>Cluster</code> is the default option for <code>externalTrafficPolicy</code>.</p>

<p>In your <code>ingress</code>, you route <code>/bleble</code> to service <code>bleble</code>, but your service name is actually <code>bleble-svc</code>. please make them consistent. Also, you would need to set your <code>servicePort</code> to 8080 as you exposed 8080 in your service configuration.</p>

<p>For internal service like <code>bleble-svc</code>, <code>Cluster IP</code> is good enough in your case as it does not need external access.</p>

<p>Hope this helps.</p>
