How to configure 2 k8s ingress objects to use the same AWS ALB?

Hunter Thompson
1 min readNov 22, 2020

--

Prior to the release of v2.0.0 of the aws-load-balancer-controller, we were not able to use the same ALB for 2 different ingress objects.

But since opensource always wins, we got a new annotation added to our arsenal, called group.name .

Let’s see 2 sample configurations :

nginx-1

apiVersion: extensions/v1beta1 
kind: Ingress
metadata:
name: "nginx-1"
namespace: "nginx1"
labels:
app: nginx-1
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/group.name: nginx
spec:
rules:
- host: nginx-1.example.com
http:
paths:
- path: /*
backend:
serviceName: "nginx-1-svc"
servicePort: 80

nginx-2

apiVersion: extensions/v1beta1 
kind: Ingress
metadata:
name: "nginx-2"
namespace: "nginx2"
labels:
app: nginx-2
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/group.name: nginx
spec:
rules:
- host: nginx-2.example.com
http:
paths:
- path: /*
backend:
serviceName: "nginx-2-svc"
servicePort: 80

These 2 ingress objects use the same AWS ALB irregardless of namespace or the services it connects to, because both have them have the same group.name: nginx annotation.

See how to set up ssl-redirection here.

--

--