<p>I am deploying K8S to AWS EKS cluster and use ALB for the deployments. I'd like to use one ALB for multiple services but I can't figure out how to share the same ALB. Every time I deploy a ingress it will override an existing one.</p>
<p>I have two config yaml file:</p>
<p>a.yaml</p>
<pre><code>---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sample-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/group.name: sample-ingress
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.order: '1'
spec:
  rules:
    - http:
        paths:
          - path: /sample-app/*
            backend:
              serviceName: sample-entrypoint
              servicePort: 80
</code></pre>
<p>b.yaml</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sample-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/group.name: sample-ingress
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.order: '2'
spec:
  rules:
    - http:
        paths:
          - path: /sample-es/*
            backend:
              serviceName: sample-es-entrypoint
              servicePort: 9200
</code></pre>
<p>I'd like both share the same ALB so I specify the group name to be the same:</p>
<p><code>alb.ingress.kubernetes.io/group.name: sample-ingress</code></p>
<p>I also specify a different order in the two files.</p>
<p>but when I run <code>kubectl apply -f a.yaml</code>, It creates a ALB with the rule I specified in the config file: <code>/sample-app/*</code>. But when I run <code>kubectl apply -f b.yaml</code>, it overrides the existing rule with <code>/sample-es/*</code>. So how can I make both share the same ALB and allow them provide different rules?</p>

<p>I guess you can create separate ingress and attach them to the same service configuration. Point the service configuration with alb, and that should work. I have a configuration for internal-facing services, please see if this works for you.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
  labels:
    app.kubernetes.io/instance: goldendev-ingress-test
    app.kubernetes.io/managed-by: Tiller
    app.kubernetes.io/name: ingress-test
    environment: DEV
    helm.sh/chart: ingress-test
  name: ingress-test
  namespace: default
spec:
  externalTrafficPolicy: Cluster
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/instance: z1
    app.kubernetes.io/name: gunicorn
  sessionAffinity: None
  type: LoadBalancer
</code></pre>
<p>Ingress.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sample-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/group.name: sample-ingress
    alb.ingress.kubernetes.io/scheme: internal
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.order: '1'
spec:
  rules:
    - http:
        paths:
          - path: /mappings/v1/hello/*
            backend:
              serviceName: ingress-test
              servicePort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sample-ingress-1
  namespace: default
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/group.name: sample-ingress
    alb.ingress.kubernetes.io/scheme: internal
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.order: '2'
spec:
  rules:
    - http:
        paths:
          - path: /mappings/v1/teams/*
            backend:
              serviceName: ingress-test-2
              servicePort: 80
</code></pre>
<p>I verified in the AWS console, it has created only 1 load balancer with service configuration.
Ingress list:</p>
<pre class="lang-sh prettyprint-override"><code> kubectl get ingress
NAME               HOSTS   ADDRESS   PORTS   AGE
sample-ingress     *                 80      19m
sample-ingress-1   *                 80      19m
</code></pre>
<p>Let me know if this helps.</p>
