<p>For example, guestbook-ui service and bbs-ui service are installed in k8s.</p>
<p>And I want to map guestbook-ui only to the 8080 listener port and bbs-ui service to the 8081 listener port to the pre-generated k8s ALB ingress.</p>
<p>However, if you write and store the following in spec, all guestbook-ui and bbs-ui services are deployed to all ports of 8080, 8081, and routing is twisted.</p>
<pre class="lang-yaml prettyprint-override"><code># skip

metadata:
  annotations:
    alb.ingress.kubernetes.io/listen-ports: '[{&quot;HTTP&quot;:8080}, {&quot;HTTP&quot;:8081}]'

# skip

spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: bbs-ui
            port:
              number: 80
        path: /*
        pathType: ImplementationSpecific
  - http:
      paths:
      - backend:
          service:
            name: guestbook-ui
            port:
              number: 80
        path: /*
        pathType: ImplementationSpecific
</code></pre>
<p>How can I deploy the service to the listener port I want?</p>

<p>There is a feature to automatically merge multiple ingress rules for all ingresses in the same <strong>ingress group</strong>. The AWS ALB ingress controller supports them with a single ALB.</p>
<pre class="lang-yaml prettyprint-override"><code>metadata:
  annotations:
    alb.ingress.kubernetes.io/group.name: my-group
</code></pre>
<blockquote>
<p>In the AWS ALB ingress controller, prior to version 2.0, each ingress object you created in Kubernetes would get its own ALB. Customers wanted a way to lower their cost and duplicate configuration by sharing the same ALB for multiple services and namespaces.
By sharing an ALB, you can still use annotations for advanced routing but share a single load balancer for a team, or any combination of apps by specifying the alb.ingress.kubernetes.io/group.name annotation. <strong>All services with the same group.name will use the same load balancer</strong>.</p>
</blockquote>
<p>So, you can create ingress like this:</p>
<pre class="lang-yaml prettyprint-override"><code>---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress1
  namespace: mynamespace
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/tags: mytag=tag
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.name: my-group
    alb.ingress.kubernetes.io/listen-ports: '[{&quot;HTTP&quot;: 8080}]'
spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: bbs-ui
            port:
              number: 80
        path: /*
        pathType: ImplementationSpecific

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress2
  namespace: mynamespace
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/tags: mytag=tag
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.name: my-group
    alb.ingress.kubernetes.io/listen-ports: '[{&quot;HTTP&quot;: 8081}]'
spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: guestbook-ui
            port:
              number: 80
        path: /*
        pathType: ImplementationSpecific
</code></pre>
<p>You can read more info about <a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.0/guide/ingress/annotations/#ingressgroup" rel="nofollow noreferrer">IngressGroup here</a>.</p>
