How to get a Virtual IP for Keepalived with bare-metal infrastructure

1.7k views Asked by At

I am configuring a High Availability load balancing based on HAProxy and Keepalived. Everywhere I do research they talk about Virtual IP like something that fell off the sky – I mean, with little to none explanation about how to get one.

By now, I have arbitrary defined a virtual ip address in the keepalived.conf like this:

virtual_ipaddress {
                10.0.0.100
        }

With both Servers running keepalived, I do ip address command in the MASTER machine and it shows inet 10.0.0.100/32 scope global eth0 next to the Public IP, which I believe is correct.

When I do service keepalived stop in the MASTER machine and run ip address in the BACKUP machine, BACKUP shows inet 10.0.0.100/32 scope global eth0, IP which effectively disappeared from MASTER.

The above mentioned behavior indicates me that the config is all right.

Now, how can I publish that Virtual IP? Do I need to buy one? If my server provider (Contabo) doesn't offer the Virtual IP service, where to buy it?

My goal is to have my Front-End API requests aiming at the Virtual IP.

Thanks very much in advance for any guidance!

1

There are 1 answers

2
Ephemeral On

Server A and server B addresses are either manually configured when setting up the servers, or obtained via dhcp. There is nothing magical about the virtual ip, other than it is not obtained in the same way. If it is your own network, you can just pick one in the same range as for the two servers, and make sure that no new servers will use it. Since you are talking about a provider, you will need to ask them if they provide floating ip addresses. 10.x.x.x is a private ip, so you can not publish that to the internet, but you could use it for example to fail over internal services.