Ingress or Service with type: LoadBalancer

吃可爱长大的小学妹 提交于 2021-02-10 14:41:09

问题


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?


回答1:


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)




回答2:


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.



来源:https://stackoverflow.com/questions/50839799/ingress-or-service-with-type-loadbalancer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!