3

Kubernetes has both Ingress (in front of a Service) and Service with type: LoadBalancer. These seem to do identical things: allow public traffic into the pods matching the service's selector. What are the benefits and drawbacks of each? In what scenarios would I choose one over the other?

robrich
  • 13,017
  • 7
  • 36
  • 63
  • Does this answer your question? [Ingress vs Load Balancer](https://stackoverflow.com/questions/45079988/ingress-vs-load-balancer) – SlightlyCuban Jan 08 '22 at 18:31

2 Answers2

4

Ingress can be used to expose many services depending on the path or even multiple applications depending on the host or domain in the request.

A load balancer always exposes one service only.

herm
  • 14,613
  • 7
  • 41
  • 62
3

Assume that AWS, GCP or Azure is where your infrastructure located

Ingress:

  • Only work if you have ingress controller such as nginx-ingress-controller, traefik,...

  • Many services could share the same ingress

  • Name based virtual hosting

  • path based routing

  • Only one AWS ELB (or GCP load balancer for Google Cloud) is needed

  • Recommend to follow this approach for most of use cases

serviceType LoadBalancer:

  • each service would create separated AWS ELB (cost inefficiency, would be super expensive if you have more and more services later)

  • Could be helpful in case you want to ensure maximum security / workload ( 1 ELB per service)

Tommy Nguyen
  • 3,403
  • 1
  • 15
  • 14
  • sums up properly. Importantly: One LoadBalancer per service will cost you much, whereas the Ingress will help you save the costs. Important consideration if there are many services. – Nitb Jun 18 '18 at 12:08
  • Do you need on ELB (AWS/GCP) or can you just use an nginx ingress controller? – DenCowboy Aug 05 '18 at 11:47