Difference between Amazon ELB and Kubernetes Ingress ?

When deploying Spring Boot Microservices on AWS Kubernetes (EKS), you need to manage how traffic is routed to your services. Two popular options are:

  1. Elastic Load Balancer (ELB)
  2. Kubernetes Ingress

1. What is ELB (Elastic Load Balancer)?

AWS Elastic Load Balancer (ELB) is a managed load balancing service that automatically distributes incoming traffic across multiple EC2 instances, containers, or Lambda functions.

Types of ELBs

  • Application Load Balancer (ALB) → Best for HTTP/HTTPS traffic & routing to microservices.
  • Network Load Balancer (NLB) → Best for low-latency TCP/UDP traffic.
  • Classic Load Balancer (CLB) → Older, general-purpose load balancer.

How ELB Works with Kubernetes (EKS)?

  • When you create a Kubernetes Service of type LoadBalancer, AWS automatically provisions an ELB.
  • Each service gets its own ELB.
  • Can be expensive when you have multiple services.

Example: Kubernetes Service with ELB

apiVersion: v1
kind: Service
metadata:
  name: myapp-service
spec:
  type: LoadBalancer
  selector:
    app: myapp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

This creates an AWS ELB that routes traffic to your service.

Pros of ELB

Fully managed by AWS (no need to install/configure).
Direct AWS integration (IAM, Security Groups, VPC).
Highly available & scalable.

Cons of ELB

✖ Each microservice needs a separate ELB (costly for multiple services).
✖ Limited routing capabilities compared to Ingress.
✖ Cannot do advanced host-based or path-based routing.

2. What is Kubernetes Ingress?

Kubernetes Ingress is a layer 7 HTTP/HTTPS traffic router that provides advanced routing rules. It helps expose multiple microservices behind a single ELB.

How Ingress Works with EKS?

  • Instead of creating multiple ELBs, Ingress Controller uses a single ALB.
  • Supports host-based and path-based routing.
  • More cost-effective than using multiple ELBs.

Example: Kubernetes Ingress with ALB

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: myapp-ingress
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
spec:
  rules:
  - host: myapp.example.com
    http:
      paths:
      - path: /users
        pathType: Prefix
        backend:
          service:
            name: user-service
            port:
              number: 80
      - path: /orders
        pathType: Prefix
        backend:
          service:
            name: order-service
            port:
              number: 80

This routes /users requests to user-service and /orders to order-service via a single ALB.

Pros of Ingress

Single ALB for multiple services (cost-efficient).
✔ Supports host-based and path-based routing.
✔ Works with AWS ALB Ingress Controller for auto-scaling.
SSL termination support (HTTPS).

Cons of Ingress

✖ Needs Ingress Controller (like AWS ALB Controller).
✖ More complex setup compared to ELB.
Not ideal for TCP/UDP services (better for HTTP-based microservices).

3. ELB vs Ingress: Side-by-Side Comparison

FeatureELB (Elastic Load Balancer)Ingress (Kubernetes Ingress Controller)
Use CaseDirectly exposes a single serviceRoutes traffic to multiple services
Traffic TypeTCP, UDP, HTTP, HTTPSHTTP, HTTPS only
RoutingBasic, per serviceAdvanced, path-based & host-based
CostEach service requires a separate ELB (costly)Uses one ALB for multiple services (cheaper)
ScalabilityAWS manages scalingKubernetes auto-scales
SSL TerminationManaged by AWSNeeds Ingress Controller configuration
IntegrationNative AWS serviceRequires ALB Ingress Controller

4. When to Use ELB vs Ingress?

Use ELB if:

✔ You have few microservices and can afford one ELB per service.
✔ You need TCP/UDP support (e.g., databases, messaging queues).
✔ You want a simpler setup without configuring Ingress.

Use Ingress if:

✔ You have multiple microservices and want one ALB for all.
✔ You need host-based or path-based routing (e.g., api.example.com/orders).
✔ You want cost savings by avoiding multiple ELBs.

5. Conclusion: Which One Should You Choose?

    For a Kubernetes-based Microservices app in AWS:

    • Use AWS ALB Ingress Controller → Best for managing multiple Spring Boot microservices efficiently.
    • Use ELB (LoadBalancer type service) only for standalone services or non-HTTP workloads.

    For most Spring Boot microservices applications in EKS, Ingress is the better option.

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *