virtual_interface_networks: [ ... ] # optional: list of CIDR networks
use_keepalived_multicast: <bool> # optional: Default is False.
vrrp_interface_network: <string>/<string> # optional: ex: 192.168.20.0/24
+ health_check_interval: <string> # optional: Default is 2s.
ssl_cert: | # optional: SSL certificate and key
-----BEGIN CERTIFICATE-----
...
monitor_port: <integer> # ex: 1967, used by haproxy for load balancer status
virtual_interface_networks: [ ... ] # optional: list of CIDR networks
first_virtual_router_id: <integer> # optional: default 50
+ health_check_interval: <string> # optional: Default is 2s.
ssl_cert: | # optional: SSL certificate and key
-----BEGIN CERTIFICATE-----
...
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.
+* ``health_check_interval``
+ Default is 2 seconds. This parameter can be used to set the interval between health checks
+ for the haproxy with the backend servers.
.. _ingress-virtual-ip:
'monitor_port': daemon_spec.ports[1] if daemon_spec.ports else spec.monitor_port,
'local_host_ip': host_ip,
'default_server_opts': server_opts,
+ 'health_check_interval': spec.health_check_interval or '2s',
}
)
config_files = {
balance static-rr
option httpchk HEAD / HTTP/1.0
{% for server in servers %}
- server {{ server.name }} {{ server.ip }}:{{ server.port }} check weight 100
+ server {{ server.name }} {{ server.ip }}:{{ server.port }} check weight 100 inter {{ health_check_interval }}
{% endfor %}
{% endif %}
{% if mode == 'tcp' %}
'balance static-rr\n '
'option httpchk HEAD / HTTP/1.0\n '
'server '
- + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100\n'
+ + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100 inter 2s\n'
}
}
'balance static-rr\n '
'option httpchk HEAD / HTTP/1.0\n '
'server '
- + haproxy_generated_conf[1][0] + ' 1::4:443 check weight 100\n'
+ + haproxy_generated_conf[1][0] + ' 1::4:443 check weight 100 inter 2s\n'
}
}
'balance static-rr\n '
'option httpchk HEAD / HTTP/1.0\n '
'server '
- + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100\n'
+ + haproxy_generated_conf[1][0] + ' 1.2.3.7:80 check weight 100 inter 2s\n'
}
}
extra_container_args: Optional[GeneralArgList] = None,
extra_entrypoint_args: Optional[GeneralArgList] = None,
custom_configs: Optional[List[CustomConfig]] = None,
+ health_check_interval: Optional[str] = None,
):
assert service_type == 'ingress'
self.ssl = ssl
self.keepalive_only = keepalive_only
self.enable_haproxy_protocol = enable_haproxy_protocol
+ self.health_check_interval = health_check_interval.strip(
+ ) if health_check_interval else None
def get_port_start(self) -> List[int]:
ports = []
if self.virtual_ip is not None and self.virtual_ips_list is not None:
raise SpecValidationError(
'Cannot add ingress: Single and multiple virtual IPs specified')
+ if self.health_check_interval:
+ valid_units = ['s', 'm', 'h']
+ m = re.search(rf"^(\d+)({'|'.join(valid_units)})$", self.health_check_interval)
+ if not m:
+ raise SpecValidationError(
+ f'Cannot add ingress: Invalid health_check_interval specified. '
+ f'Valid units are: {valid_units}')
yaml.add_representer(IngressSpec, ServiceSpec.yaml_representer)