From bb69368fb5cd1def58cbe638dbd4d3bcf63e431f Mon Sep 17 00:00:00 2001 From: Luis Domingues Date: Tue, 20 Jun 2023 09:07:57 +0200 Subject: [PATCH] cephadm: Add parameter to set keepalived's virtual router id When deploying more than 1 ingress, two instances of keepalived can be generated with the same virtual_router_id. This commit adds posibility to change the virtual_router_id of keepalived from the spec file. Signed-off-by: Luis Domingues --- doc/cephadm/services/rgw.rst | 6 ++++++ src/pybind/mgr/cephadm/services/ingress.py | 1 + .../cephadm/templates/services/ingress/keepalived.conf.j2 | 2 +- src/python-common/ceph/deployment/service_spec.py | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/cephadm/services/rgw.rst b/doc/cephadm/services/rgw.rst index 740f74bb9b5d8..20ec39a88dd1a 100644 --- a/doc/cephadm/services/rgw.rst +++ b/doc/cephadm/services/rgw.rst @@ -272,6 +272,7 @@ It is a yaml format file with the following properties: frontend_port: # ex: 8080 monitor_port: # ex: 1967, used by haproxy for load balancer status virtual_interface_networks: [ ... ] # optional: list of CIDR networks + first_virtual_router_id: # optional: default 50 ssl_cert: | # optional: SSL certificate and key -----BEGIN CERTIFICATE----- ... @@ -315,6 +316,11 @@ where the properties of this service specification are: By default, cephadm will configure keepalived to use the same interface where the VIPs are for VRRP communication. If another interface is needed, it can be set via ``vrrp_interface_network`` with a network to identify which ethernet interface to use. +* ``first_virtual_router_id`` + Default is 50. When deploying more than 1 ingress, this parameter can be used to ensure each + keepalived will have different virtual_router_id. In the case of using ``virtual_ips_list``, + each IP will create its own virtual router. So the first one will have ``first_virtual_router_id``, + second one will have ``first_virtual_router_id`` + 1, etc. Valid values go from 1 to 255. .. _ingress-virtual-ip: diff --git a/src/pybind/mgr/cephadm/services/ingress.py b/src/pybind/mgr/cephadm/services/ingress.py index 664c291c46abf..134c9ce9a39d9 100644 --- a/src/pybind/mgr/cephadm/services/ingress.py +++ b/src/pybind/mgr/cephadm/services/ingress.py @@ -352,6 +352,7 @@ class IngressService(CephService): 'interface': interface, 'vrrp_interface': vrrp_interface, 'virtual_ips': virtual_ips, + 'first_virtual_router_id': spec.first_virtual_router_id, 'states': states, 'priorities': priorities, 'other_ips': other_ips, diff --git a/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 b/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 index 006db52ea112a..dfab7e342451d 100644 --- a/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 +++ b/src/pybind/mgr/cephadm/templates/services/ingress/keepalived.conf.j2 @@ -12,7 +12,7 @@ vrrp_instance VI_{{ x }} { state {{ states[x] }} priority {{ priorities[x] }} interface {{ vrrp_interface }} - virtual_router_id {{ 50 + x }} + virtual_router_id {{ first_virtual_router_id + x }} advert_int 1 authentication { auth_type PASS diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index 232586bead3f1..86b3a155246a5 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -1055,6 +1055,7 @@ class IngressSpec(ServiceSpec): virtual_interface_networks: Optional[List[str]] = [], use_keepalived_multicast: Optional[bool] = False, vrrp_interface_network: Optional[str] = None, + first_virtual_router_id: Optional[int] = 50, unmanaged: bool = False, ssl: bool = False, keepalive_only: bool = False, @@ -1089,6 +1090,7 @@ class IngressSpec(ServiceSpec): self.virtual_interface_networks = virtual_interface_networks or [] self.use_keepalived_multicast = use_keepalived_multicast self.vrrp_interface_network = vrrp_interface_network + self.first_virtual_router_id = first_virtual_router_id self.unmanaged = unmanaged self.ssl = ssl self.keepalive_only = keepalive_only -- 2.39.5