javaamazon-web-servicesspring-bootamazon-eksamazon-elb

Common Load Balancer For Spring boot Micro serivce Projects Using AWS EKS and ELB


Currently I am working on migration from monolithic application into microservice oriented architecture using spring boot , hibernate , docker and kubernetes technological stack. My backend contains 10 projects with 120 microservice end points totally. Each springboot project having average of 10-12 end points. And I am trying to deploy these all end points using AWS EKS cluster and need to use load balancer ELB.

Confusion on Common LB

If I need to get all of these microservice using loadbalancer-ip/domain/module/end-point, How can I setup common load balancer in my EKS cluster.

Preparation

Currently I am trying to implement application load balancer method by adding ingress in my deployment yml files. So Do I need to add 10 different ingress for my 10 springboot project or Can I directly add target group by login in AWS Console -> ELB configuration?

I am totally confused here. Can anyone suggest any documentations to read Or guide me to resolve this easier way?

Update

Asset , Communications, Admin are 3 separate spring boot projects.I divided project according to my project. Each project contains different end points.

And i need like the following for ex Loadbalancer-ip:port1/asset/loadasset Loadbalancer-ip:port2/communication/loademails Loadbalancer-ip:port3/admin/loadadmin

Like these i need to have. So even if end points are in separate springboot project, i should get under a common load balancer and in URL i can separate according to different domains. Since i created projects according to project domains


Solution

  • You can use a single Application Load Balancer (ALB) for all your Spring Boot microservices deployed on AWS EKS by configuring a shared Ingress Controller, such as the AWS ALB Ingress Controller (now called AWS Load Balancer Controller).

    Recommended Setup

    1.Install the AWS Load Balancer Controller

    2. Use One Ingress per Service (with Shared ALB)

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: service-a-ingress
      annotations:
        alb.ingress.kubernetes.io/group.name: my-shared-alb
        alb.ingress.kubernetes.io/scheme: internet-facing
    spec:
      rules:
        - host: my-alb.example.com
          http:
            paths:
              - path: /service-a
                pathType: Prefix
                backend:
                  service:
                    name: service-a
                    port:
                      number: 80
    

    3.Use Path-Based Routing

    my-alb.example.com/service-a → microservice A
    my-alb.example.com/service-b → microservice B