Add haproxy_backend_only flag to service template

Addition of a `haproxy_backend_only` flag to the service template
for instances in which a frontend service uses ACLs to propgate
requests to multiple backend services, and not all backend services
require a corresponding frontend. This should prevent the
proliferation of spurious frontend services.

Change-Id: I8c419be82cffd289ffcc5086afac923d6eb1a78a
This commit is contained in:
Danny Meloy 2020-08-21 12:07:39 +01:00 committed by Daniel Meloy
parent 4e47093565
commit 8120c9a3c5
2 changed files with 15 additions and 0 deletions

View File

@ -356,3 +356,16 @@ Here is an example that shows how to achieve the goal
This will add two acl rules ``path_sub -i write`` and ``path_sub -i query`` to
the front end and use the backend specified in the rule. If no backend is specified
it will use a default ``haproxy_service_name`` backend.
If a frontend service directs to multiple backend services using ACLs, and a
backend service does not require its own corresponding front-end, the
`haproxy_backend_only` option can be specified:
.. code-block:: yaml
- service:
haproxy_service_name: influxdb
haproxy_backend_only: true # Directed by the 'influxdb-relay' service above
haproxy_backend_nodes:
- name: influxdb-service
ip_addr: 10.100.10.10

View File

@ -29,6 +29,7 @@
{% set vip_binds = item.service.haproxy_bind %}
{% endif -%}
{% if not item.service.haproxy_backend_only | default(false) %}
{% for vip_bind in vip_binds %}
{% if item.service.haproxy_redirect_http_port is defined and item.service.haproxy_ssl %}
{% if (loop.index == 1 or item.service.haproxy_ssl_all_vips | default(false) | bool) %}
@ -78,6 +79,7 @@ frontend {{ item.service.haproxy_service_name }}-front-{{ loop.index }}
mode {{ item.service.haproxy_balance_type }}
default_backend {{ item.service.haproxy_service_name }}-back
{% endfor %}
{% endif %}
{% set backend_options = item.service.haproxy_backend_options|default([]) %}
{% set backend_arguments = item.service.haproxy_backend_arguments|default([]) %}