Sorry if I’m missing something here, but according to the keepalived man page:
A virtual_server can be a declaration of one of **<IPADDR> [<PORT>]** , **fwmark <INTEGER>** or **group <STRING>**
But the conf-node name, even if it may be an arbitrary string, will be transformed into keepalived.conf
like this:
virtual_server {{ vserver }} {{ vserver_config.port }} {
The doc says keepalived expects an IP and optionally a port for this mode (and maybe you could use a name that resolves to an IP instead, but that is IMO a hack). Currently the config forces you to use an IP as the node name (and no port) if you don’t want to use fwmark. So we can only have one virtual-server for one IP even if keepalived accepts multiple IP:port servers. And yes, you can do multiple ports with fwmark, but not translate those to other port numbers afaik.
The way I see it there are some possible fixes:
Make the virtual-server
node name arbitrary by definition and move address
into the config object, alternatively in addition move port
under the address
node. Or use addr:port as the node name and deprecate the port
node. Then when rendering the addr:port string, simply replace ':'
by ' '
.
set high-availability virtual-server my_first_server address 1.2.3.4 port 80
set high-availability virtual-server 1.2.3.4:80
is transformed into keepalived.conf
:
virtual_server 1.2.3.4 80 { }
WIthout port number:
set high-availability virtual-server my_first_server address 1.2.3.4
set high-availability virtual-server 1.2.3.4
is transformed into keepalived.conf
:
virtual_server 1.2.3.4 { }
or specify explicitly what type of virtual server we have
set high-availability virtual-server addr_port 1.2.3.4:80
set high-availability virtual-server fwmark 111
set high-availability virtual-server group my_group
(added the group
option here even if it not currently supported).
alternatively, implicit type by parsing node names as ip:port, integer or string.
set high-availability virtual-server 1.2.3.4:80 real-server 5.6.7.8 port 8080
set high-availability virtual-server 111 real-server 5.6.7.8
set high-availability virtual-server my_group ...
No redundant arbitrary node names in these cases, perhaps add a description
node instead.