Ingress or Service with type: LoadBalancer

6/13/2018

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
kubernetes
kubernetes-ingress
kubernetes-service

2 Answers

6/13/2018

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
Source: StackOverflow

6/13/2018

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
Source: StackOverflow