Skip to content

Commit

Permalink
[IMP] Add traefik necessary rules to expose database service (compati…
Browse files Browse the repository at this point in the history
…ble with Traefik 3)
  • Loading branch information
josep-tecnativa committed May 8, 2024
1 parent e948e79 commit 842cba0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion _traefik2_labels.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
{%- endif %}
{%- endmacro %}

{# Same on HostSNI #}
{%- macro domains_rule_sni(domain_group) -%}
HostSNI(
{%- for host in domain_group.hosts -%}
`{{ host }}`
{%- if not loop.last %}, {% endif %}
{%- endfor -%}
)
{%- if domain_group.path_prefixes %} && {{ path_prefix_rule(domain_group.path_prefixes) }}
{%- endif %}
{%- endmacro %}

{%- macro key(project_name, odoo_version, suffix) %}
{{- '%s-%.1f-%s'|format(project_name, odoo_version, suffix)|replace('.', '-') }}
{%- endmacro %}
Expand Down Expand Up @@ -212,7 +224,9 @@
{%- macro database(domain_groups_list, cidr_whitelist, key, port, project_name) %}
{#- Service #}
traefik.tcp.services.{{ key }}-database.loadbalancer.server.port: 5432

traefik.tcp.routers.{{ key }}-database.tls: "true"
traefik.tcp.routers.{{ key }}-database.tls.certResolver: letsencrypt
traefik.tcp.routers.{{ key }}-database.rule: {{ domains_rule_sni(domain_groups_list) }}
{%- if cidr_whitelist %}
{#- Declare whitelist middleware #}
? traefik.tcp.middlewares.{{ key }}-whitelist.IPWhiteList.sourceRange
Expand Down

0 comments on commit 842cba0

Please sign in to comment.