Correctly handle disabled entrypoints

This commit is contained in:
Daniel Berteaud 2023-10-16 14:01:16 +02:00
parent 56771f4044
commit 0efc680268
2 changed files with 19 additions and 16 deletions

View File

@ -12,25 +12,28 @@ entryPoints:
[[- range $name, $def := .traefik.entrypoints ]]
[[- if or (not (has $def "enabled")) ($def.enabled) ]]
[[ $name ]]:
address: ":{{ env "NOMAD_PORT_[[ $name | regexp.Replace "[\\.\\-]" "_" ]]" }}[[ if has $def "protocol" ]]/[[ $def.protocol ]][[ end ]]"
[[- if gt (len $.traefik.trusted_proxies) 0 ]]
[[- if gt (len $.traefik.trusted_proxies) 0 ]]
proxyProtocol:
trustedIPs:[[ range $idx, $ip := $.traefik.trusted_proxies ]]
- [[ $ip ]][[ end ]]
[[- if has $def "http" ]]
- [[ $ip ]]
[[ end ]]
[[- if has $def "http" ]]
http:
[[ $def.http | toYAML | indent 6 ]]
[[- end ]]
[[- end ]]
transport:
lifeCycle:
requestAcceptGraceTimeout: 4
[[- if and (has $def "middlewares") (gt (len $def.middlewares)) ]]
[[- if and (has $def "middlewares") (gt (len $def.middlewares)) ]]
middlewares:
[[- range $def.middlewares ]]
[[- range $def.middlewares ]]
- [[ . ]]
[[- end ]]
[[- end ]]
[[- end ]]
[[- end ]]
[[- end ]]
[[- end ]]
[[- end ]]

View File

@ -11,18 +11,18 @@ job [[ .traefik.instance | toJSON ]] {
network {
mode = "bridge"
[[- range $name, $def := .traefik.entrypoints ]]
[[- if or (not (has $def "enabled")) ($def.enabled) ]]
[[- range $name, $def := .traefik.entrypoints ]]
[[- if or (not (has $def "enabled")) ($def.enabled) ]]
port "[[ $name ]]" {
[[- if has $def "static" ]]
[[- if has $def "static" ]]
static = [[ $def.static ]]
[[- end ]]
[[- if has $def "to" ]]
[[- end ]]
[[- if has $def "to" ]]
to = [[ $def.to ]]
[[- end ]]
[[- end ]]
}
[[- end ]]
[[- end ]]
[[- end ]]
[[- end ]]
port "metrics" {}
}