Loadbalancing in kubernetes

3/30/2019

I read a bout metalLB in http://blog.cowger.us/2018/07/25/using-kubernetes-externaldns-with-a-home-bare-metal-k8s.html the writers said

Bare metal cluster operators are left with two lesser tools to bring user traffic into their clusters, “NodePort” and “externalIPs” services. Both of these options have significant downsides for production use, which makes bare metal clusters second class citizens in the Kubernetes ecosystem.

I want to know what is this significant downsides.

-- yasin lachini
kubernetes

1 Answer

3/30/2019

A Service with type: NodePort would open the same port on all of the nodes enabling clients to direct their traffic to any of the nodes and kube-proxy can balance the traffic between Pods from that point on. You face 3 problems here:

  1. Unless you are happy with depending on a single node you'd need to create your own load balancing solution to target multiple (or even all) nodes. This is doable of course but you need extra software or hardware plus configuration
  2. For configuration above you also need a mechanism to discover the IP addresses of the nodes, keep that list updated and monitor for health of nodes. Again, doable but extra pain
  3. NodePort only supports picking a port number from a specific range (default is 30000-32767). The range can be modified but you won't be able to pick your favourite ports like 80 or 443 this way. Again, not a huge problem if you have an external load balancing solution which will hide this implementation detail

As for Service with type: ClusterIP (default) and externalIPs: [...] (must specify IP address(es) of node(s) there your problems will be:

  1. You need some method to pick some nodes that are healthy and keep the Service object updated with that list. Doable but requires extra automation.
  2. Same 1., for NodePort
  3. Although you get to pick arbitrary port numbers here (so 80, 443, 3306 are okay) your will need do some housekeeping to avoid attempting to use the same port number on the same node from two different Service objects. Once again, doable but you probably have something better to do
-- Janos Lenart
Source: StackOverflow