diff --git a/docs/ENVIRONMENT.rst b/docs/ENVIRONMENT.rst index dd78d35e..bb04bd83 100644 --- a/docs/ENVIRONMENT.rst +++ b/docs/ENVIRONMENT.rst @@ -49,6 +49,7 @@ Consul - **PATRONI\_CONSUL\_CHECKS**: (optional) list of Consul health checks used for the session. By default an empty list is used. - **PATRONI\_CONSUL\_REGISTER\_SERVICE**: (optional) whether or not to register a service with the name defined by the scope parameter and the tag master, replica or standby-leader depending on the node's role. Defaults to **false** - **PATRONI\_CONSUL\_SERVICE\_CHECK\_INTERVAL**: (optional) how often to perform health check against registered url +- **PATRONI\_CONSUL\_SERVICE\_CHECK\_TLS\_SERVER\_NAME**: (optional) overide SNI host when connecting via TLS, see also `consul agent check API reference `__. Etcd ---- diff --git a/docs/SETTINGS.rst b/docs/SETTINGS.rst index 7433d438..63e7f1c5 100644 --- a/docs/SETTINGS.rst +++ b/docs/SETTINGS.rst @@ -132,6 +132,7 @@ Most of the parameters are optional, but you have to specify one of the **host** - **register\_service**: (optional) whether or not to register a service with the name defined by the scope parameter and the tag master, replica or standby-leader depending on the node's role. Defaults to **false**. - **service\_tags**: (optional) additional static tags to add to the Consul service apart from the role (``master``/``replica``/``standby-leader``). By default an empty list is used. - **service\_check\_interval**: (optional) how often to perform health check against registered url. +- **service\_check\_tls\_server\_name**: (optional) overide SNI host when connecting via TLS, see also `consul agent check API reference `__. The ``token`` needs to have the following ACL permissions: diff --git a/patroni/config.py b/patroni/config.py index 8633d447..5996f68e 100644 --- a/patroni/config.py +++ b/patroni/config.py @@ -350,9 +350,9 @@ class Config(object): name, suffix = (param[8:].split('_', 1) + [''])[:2] if suffix in ('HOST', 'HOSTS', 'PORT', 'USE_PROXIES', 'PROTOCOL', 'SRV', 'SRV_SUFFIX', 'URL', 'PROXY', 'CACERT', 'CERT', 'KEY', 'VERIFY', 'TOKEN', 'CHECKS', 'DC', 'CONSISTENCY', - 'REGISTER_SERVICE', 'SERVICE_CHECK_INTERVAL', 'NAMESPACE', 'CONTEXT', - 'USE_ENDPOINTS', 'SCOPE_LABEL', 'ROLE_LABEL', 'POD_IP', 'PORTS', 'LABELS', - 'BYPASS_API_SERVICE', 'KEY_PASSWORD', 'USE_SSL', 'SET_ACLS') and name: + 'REGISTER_SERVICE', 'SERVICE_CHECK_INTERVAL', 'SERVICE_CHECK_TLS_SERVER_NAME', + 'NAMESPACE', 'CONTEXT', 'USE_ENDPOINTS', 'SCOPE_LABEL', 'ROLE_LABEL', 'POD_IP', + 'PORTS', 'LABELS', 'BYPASS_API_SERVICE', 'KEY_PASSWORD', 'USE_SSL', 'SET_ACLS') and name: value = os.environ.pop(param) if suffix == 'PORT': value = value and parse_int(value) diff --git a/patroni/dcs/consul.py b/patroni/dcs/consul.py index 8b4c25bc..10886c6e 100644 --- a/patroni/dcs/consul.py +++ b/patroni/dcs/consul.py @@ -233,6 +233,7 @@ class Consul(AbstractDCS): if self._register_service: self._set_service_name() self._service_check_interval = config.get('service_check_interval', '5s') + self._service_check_tls_server_name = config.get('service_check_tls_server_name', None) if not self._ctl: self.create_session() @@ -458,6 +459,8 @@ class Consul(AbstractDCS): conn_parts = urlparse(data['conn_url']) check = base.Check.http(api_parts.geturl(), self._service_check_interval, deregister='{0}s'.format(self._client.http.ttl * 10)) + if self._service_check_tls_server_name is not None: + check['TLSServerName'] = self._service_check_tls_server_name tags = self._service_tags[:] tags.append(role) self._previous_loop_service_tags = self._service_tags