Xerphiel
Xerphiel

Reputation: 1133

Kubernetes - Anyway to load balance requests to a service running on multiple nodes without an external load balancer?

So running and scaling a deployment running multiple pods on a single node works nicely, and when exposing the service with a type "nodePort" nicely balances requests to the virtual IP between the multiple pods on that individual node.

I've since added an additional node to my cluster, and when exposing the Service using nodePort and then running pods over 2 nodes, I of course need to specify each host specifically to hit the endpoints running in different pods on different nodes.

I would like to send requests to a single VIP and load balance accross the different nodes. I am running this small cluster on my home network, so my question is, is there anyway to send requests to a single VIP, and load balance across the nodes / pods without using an external load-balancer? E.g., is there some config within kubernetes to handle this?

I tried using a service type load balancer (instead of node port) but this didn't load balance accross nodes.

Upvotes: 1

Views: 814

Answers (2)

Mady
Mady

Reputation: 1

In my view, if all your pods in both the nodes are attached to the same clusterIP then all pods will be load balanced between the 2 nodes. ClusterIp service works for you as internal load balancer..

Upvotes: 0

silverfox
silverfox

Reputation: 5272

Take a look at Keepalived in Kubernetes.

The idea is to expose a Virtual IP (VIP) address per service, outside of the kubernetes cluster. keepalived then uses VRRP to sync this "mapping" in the local network. With 2 or more instance of the pod running in the cluster is possible to provide HA using a single VIP address.

Upvotes: 1

Related Questions