From 5acd526ce7645a96cc57cc0b3e8f7ce1174d069e Mon Sep 17 00:00:00 2001 From: Joao Morais Date: Wed, 16 Jan 2019 22:22:25 -0200 Subject: [PATCH] =?UTF-8?q?Use=20SRV=20records=20on=20dns=20resolver=20if?= =?UTF-8?q?=20backend=20port=20isn=E2=80=99t=20a=20valid=20number?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rootfs/etc/haproxy/template/haproxy.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rootfs/etc/haproxy/template/haproxy.tmpl b/rootfs/etc/haproxy/template/haproxy.tmpl index 93bed1da5..fdd471c32 100644 --- a/rootfs/etc/haproxy/template/haproxy.tmpl +++ b/rootfs/etc/haproxy/template/haproxy.tmpl @@ -155,7 +155,8 @@ backend {{ $backend.Name }} {{- end }} {{- $BackendSlots := index $ing.BackendSlots $backend.Name }} {{- if $BackendSlots.UseResolver }} - server-template server-dns {{ $BackendSlots.TotalSlots }} {{ $backend.Service.Name }}.{{ $backend.Service.Namespace }}.svc.{{ $cfg.DNSClusterDomain }}:{{ $backend.Port }} resolvers {{ $BackendSlots.UseResolver }} resolve-prefer ipv4 init-addr none +{{- $portIsNumber := ne (int64 $backend.Port.String) 0 }} + server-template server-dns {{ $BackendSlots.TotalSlots }} {{ if not $portIsNumber }}_{{ $backend.Port }}._tcp.{{ end }}{{ $backend.Service.Name }}.{{ $backend.Service.Namespace }}.svc.{{ $cfg.DNSClusterDomain }}{{ if $portIsNumber }}:{{ $backend.Port }}{{ end }} resolvers {{ $BackendSlots.UseResolver }} resolve-prefer ipv4 init-addr none {{- template "backend" map $cfg $backend }} {{- else }} {{- range $slot := $BackendSlots.Slots }}