2

I use MetalLB and Nginx-ingress controller to provide internet access to my apps. I see that in most configurations, the service is set to ClusterIP, as the ingress will send traffic there.

My question is: does this end up with double load balancing, that is, one from MetalLB to my ingress, and another from my ingress to the pods via ClusterIP?

If so, is this how it is supposed to be, or is there a better way?

old_timer
  • 69,149
  • 8
  • 89
  • 168
francisaugusto
  • 1,077
  • 1
  • 12
  • 29
  • What do you mean with "to my ingress"? do you mean "to my nginx"? – Jonas Jan 15 '23 at 14:46
  • @Jonas yes, to my Nginx-ingress – francisaugusto Jan 15 '23 at 14:49
  • 1
    I don't have any source but yes that's what happen. Some ingress might be able to configure the external LB to send traffic directly to the pods but that requires some network stuff. – Gaël J Jan 15 '23 at 16:53
  • Thanks! It would be nicer if we could have some kind of passthrough, like an ingress type that would send traffic directly to the pods via its load balancer address. I imagine that MetalLB with BGP creates traffic that is less dependent on one single pod, while a clusterIP service might not do that. But I am still wrapping my head around this. – francisaugusto Jan 15 '23 at 17:05

1 Answers1

3

Metallb doesn't receive and forward any traffic, so

from MetalLB to my ingress

doesn't really make sense. Metallb just configures kubernetes services with an external ip and tells your surrounding infrastructure where to find it. Still with your setup there will be double load-balancing:

Traffic reaches your cluster and is load-balanced between your nginx pods. Nginx handles the request and forwards it to the application, which will result in a second load-balancing.

But this makes total sense, because if you're using an ingress-controller, you don't want all incoming traffic to go through the same pod.

Using an ingress-controller with metallb can be done and can improve stability while performing updates on you application, but it's not required.

Metallb is a solution to implement kubernetes services of type LoadBalancing when there is no cloud provider to do that for you.

So if you don't need layer 7 load-balancing mechanism you can instead of using a service of type ClusterIP with an ingress-controller just use a service of type LoadBalancing. Metallb will give that service an external ip from your pool and announce it to it's peers.

In that case, when traffic reaches the cluster it will only be load-balanced once.

Chris
  • 5,109
  • 3
  • 19
  • 40
  • Thanks for the answer, @chris. It makes sense to me now - it's just that it would be nice if ingresses could cooperate with services in a way where just one load balancing could be used. – francisaugusto Jan 16 '23 at 10:08