Multiple Ingresses with Different Namespaces Using a Single Load Balancer
•
2 min read
Summary
Are you struggling with the cost of creating an Ingress for every namespace on EKS? There’s a solution: use a single load balancer to route traffic based on the host. In this blog, we’ll show you how to achieve this through a simple annotation.
When you create an Ingress on EKS, AWS automatically generates a load balancer and routes traffic to it. However, when you have multiple namespaces with their own Ingress, the cost can add up quickly. This is where a single load balancer comes in handy.
By using a single load balancer, you can route traffic based on the host. This can be accomplished through the use of an annotation as follows.
alb.ingress.kubernetes.io/group.name: my-team.awesome-group
Sample Ingress YAML
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: echoserver
namespace: "<your_namespace>"
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/group.name: "<your_group>"
spec:
ingressClassName: alb
rules:
- host: "<your_host>"
http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: <your_service>
port:
number: 80