if extra_ssl_cert_provided and spec.generate_cert:
raise OrchestratorError("Cannot provide ssl_certificate in combination with generate_cert")
+ # pick ip RGW should bind to
+ ip_to_bind_to = ''
+ if spec.only_bind_port_on_networks and spec.networks:
+ assert daemon_spec.host is not None
+ ip_to_bind_to = self.mgr.get_first_matching_network_ip(daemon_spec.host, spec) or ''
+ if ip_to_bind_to:
+ daemon_spec.port_ips = {str(port): ip_to_bind_to}
+ else:
+ logger.warning(
+ f'Failed to find ip in {spec.networks} for host {daemon_spec.host}. '
+ f'{daemon_spec.name()} will bind to all IPs'
+ )
+ elif daemon_spec.ip:
+ ip_to_bind_to = daemon_spec.ip
+
if ftype == 'beast':
if spec.ssl:
- if daemon_spec.ip:
+ if ip_to_bind_to:
args.append(
- f"ssl_endpoint={build_url(host=daemon_spec.ip, port=port).lstrip('/')}")
+ f"ssl_endpoint={build_url(host=ip_to_bind_to, port=port).lstrip('/')}")
else:
args.append(f"ssl_port={port}")
if spec.generate_cert:
elif not extra_ssl_cert_provided:
args.append(f"ssl_certificate=config://rgw/cert/{spec.service_name()}")
else:
- if daemon_spec.ip:
- args.append(f"endpoint={build_url(host=daemon_spec.ip, port=port).lstrip('/')}")
+ if ip_to_bind_to:
+ args.append(f"endpoint={build_url(host=ip_to_bind_to, port=port).lstrip('/')}")
else:
args.append(f"port={port}")
elif ftype == 'civetweb':
if spec.ssl:
- if daemon_spec.ip:
+ if ip_to_bind_to:
# note the 's' suffix on port
- args.append(f"port={build_url(host=daemon_spec.ip, port=port).lstrip('/')}s")
+ args.append(f"port={build_url(host=ip_to_bind_to, port=port).lstrip('/')}s")
else:
args.append(f"port={port}s") # note the 's' suffix on port
if spec.generate_cert:
elif not extra_ssl_cert_provided:
args.append(f"ssl_certificate=config://rgw/cert/{spec.service_name()}")
else:
- if daemon_spec.ip:
- args.append(f"port={build_url(host=daemon_spec.ip, port=port).lstrip('/')}")
+ if ip_to_bind_to:
+ args.append(f"port={build_url(host=ip_to_bind_to, port=port).lstrip('/')}")
else:
args.append(f"port={port}")
else:
extra_container_args: Optional[GeneralArgList] = None,
extra_entrypoint_args: Optional[GeneralArgList] = None,
custom_configs: Optional[List[CustomConfig]] = None,
+ only_bind_port_on_networks: bool = False,
rgw_realm_token: Optional[str] = None,
update_endpoints: Optional[bool] = False,
zone_endpoints: Optional[str] = None, # comma separated endpoints list
self.update_endpoints = update_endpoints
self.zone_endpoints = zone_endpoints
self.zonegroup_hostnames = zonegroup_hostnames
+ #: Whether to limit ip we bind to to what's specified in "networks" parameter
+ self.only_bind_port_on_networks = only_bind_port_on_networks
#: To track op metrics by user config value rgw_user_counters_cache must be set to true
self.rgw_user_counters_cache = rgw_user_counters_cache