Yes, it's possible. CLUSTERIP
target is designed specifically for that.
It is configured by assigning the same IP address to all nodes, but filtering access to roughly 1/N of all connections are processed by each node. It is designed so that if the N nodes are configured with all the same settings except --local-node
takes values 0, 1, ..., N-1, then all connections are processed — each connection will be assigned to one and only one node.
However, it's alone is not enough. When node is down, the share of connections that should have been processed by it will not be considered by anyone. To fix that, all remaining nodes need to be reconfigured with new values of --total-nodes
and --local-node
. For this reason, it is not designed to be run by hand. You need some agent which will constantly check all the nodes and reconfigure the CLUSTERIP on all nodes on the fly.
Usually Pacemaker + Corosync clustering stack is used, which has ClusterIP agent to control this kind of load balancing. It will do all the dirty work: check which nodes are alive, configure the iptables rules; it can also do more, such as defining "alive" as "Apache service is running and accepting connections". Overall Pacemaker is very capable clustering stack.
As this module is unable to consider the actual load of the nodes, it is not used for end services much. However, if you want to have several higher-level load balancing HAProxy or Nginx nodes which intelligently balance actual web (or other) backends, to make the balancer farm itself highly available you setup CLUSTERIP-style load balancing for them.