Divyansh Khandelwal
Divyansh Khandelwal

Reputation: 29

How to setup Ingress for AWS EKS Application Load Balancer(ALB) for multiple microservices?

I have 5 microservices which I wish to allow external traffic to. These microservices will be hosted on different subdomains. I am using K8s cluster on EKS and have the cluster and other services running. There seems to be quite a lot of confusion when it comes to Ingress. I have configured the ALB ingress controller by following this tutorial on eksworkshop. This worked for me and I am able to deploy the 2048 game as the tutorial explains.

Now what I wish to develop is an Ingress resource as following:

# apiVersion: networking.k8s.io/v1beta1
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    name: cluster-ingress
    annotations:
        kubernetes.io/ingress.class: alb
        alb.ingress.kubernetes.io/scheme: internet-facing
        alb.ingress.kubernetes.io/target-type: ip
spec:
    rules:
        - host: app.my-domain.com
          http:
              paths:
                  - path: /*
                    backend:
                        serviceName: app-cluster-ip-service
                        servicePort: 3000

        - host: ms1.my-domain.com
          http:
              paths:
                  - path: /*
                    backend:
                        serviceName: ms1-cluster-ip-service
                        servicePort: 8000
        - host: ms2.my-domain.com
          http:
              paths:
                  - path: /*
                    backend:
                        serviceName: ms2-cluster-ip-service
                        servicePort: 2000
        - host: ms3.my-domain.com
          http:
              paths:
                  - path: /*
                    backend:
                        serviceName: ms3-cluster-ip-service
                        servicePort: 4000
        - host: website.my-domain.com
          http:
              paths:
                  - path: /*
                    backend:
                        serviceName: website-cluster-ip-service
                        servicePort: 3333

So here are my doubts

  1. How do I configure ingress to redirect to different ports based on the domain? (when I was using Nginx, there is a provision to set Upstream and then Nginx routes traffic accordingly)
  2. What is the procedure to link it to my registered domain? (TLS certificates with Cert manager Lets Encrypt)
  3. What should I put in my DNS records for all the subdomains? (A records/CNAME of ALB) And do all the 5 subdomains have the same record/config?

I use Cloudflare for DNS management if that helps.

Upvotes: 2

Views: 3052

Answers (1)

Kane
Kane

Reputation: 8172

  1. Application load balancer uses the rules to conditional route the requests to different hosts/paths. So AWS load balancer controller supports that feature via annotations, see doc for detail.
  2. You can cert manager to manage the certificates of your domain. Also AWS load balancer supports specifying the certificate stored in ACM if you use a wildcard cert.
  3. Yes, you have to create multiple DNS records for your domains whatever the ingress controller you’re using. You can have a look at external-dns to make it automatically.

Upvotes: 1

Related Questions