Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between exposing nginx as load balancer vs Ingress controller?

I understood Ingress can be used when we want to expose multiple service/routes with a single Load Balancer / public IP.

Now I want to expose my Nginx server to public. I have two choices

  1. Set service type as LoadBalancer voila I got public IP
  2. Use Nginx Ingress Controller

Now I can get my job done with Option 1 when or why would I choose Option 2 whats the advantage of having nginx with Ingress without Ingress ?

like image 878
Siva Avatar asked Jun 21 '18 10:06

Siva


People also ask

Is ingress controller the same as load balancer?

While ingresses and load balancers have a lot of overlap in functionality, they behave differently. The main difference is ingresses are native objects inside the cluster that can route to multiple services, while load balancers are external to the cluster and only route to a single service.

What is the difference between Nginx and ingress controller?

Ingress , or ingress rules are the rules that ingress controller follows to distribute the load. Ingress controller get the packet, checks ingress rules and determines to which service to deliver the packet. Nginx ingress controller uses LoadBalancer type service actually as entrypoint to the cluster.

Is Nginx Ingress a load balancer?

Coming to your query Ingress-nginx is not a load balancer but on a broader lever can help you with load balancing.

What is the difference between load balancer and ingress in Kubernetes?

A Kubernetes application load balancer is a type of service, while Kubernetes ingress is a collection of rules, not a service. Instead, Kubernetes ingress sits in front of multiple services and acts as the entry point for an entire cluster of pods.


1 Answers

There is a difference between ingress rule (ingress) and ingress controller. So, technically, nginx ingress controller and LoadBalancer type service are not comparable. You can compare ingress resource and LoadBalancer type service, which is below.

Generally speaking:

LoadBalancer type service is a L4(TCP) load balancer. You would use it to expose single app or service to outside world. It would balance the load based on destination IP address and port.

Ingress type resource would create a L7(HTTP/S) load balancer. You would use this to expose several services at the same time, as L7 LB is application aware, so it can determine where to send traffic depending on the application state.

ingress and ingress controller relation:

Ingress, or ingress rules are the rules that ingress controller follows to distribute the load. Ingress controller get the packet, checks ingress rules and determines to which service to deliver the packet.

Nginx Ingress Controller

Nginx ingress controller uses LoadBalancer type service actually as entrypoint to the cluster. Then is checks ingress rules and distributes the load. This can be very confusing. You create an ingress resource, it creates the HTTP/S load balancer. It also gives you an external IP address (on GKE, for example), but when you try hitting that IP address, the connection is refused.

Conclusions:

You would use Loadbalancer type service if you would have a single app, say myapp.com that you want to be mapped to an IP address.

You would use ingress resource if you would have several apps, say myapp1.com, myapp1.com/mypath, myapp2.com, .., myappn.com to be mapped to one IP address.

As the ingress is L7 it is able to distinguish between myapp1.com and myapp1.com/mypath, it is able to route the traffic to the right service.

like image 183
suren Avatar answered Oct 19 '22 09:10

suren