Skip to content

Commit

Permalink
Use SRV records on dns resolver if backend port isn’t a valid number
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmoraisjr committed Jan 17, 2019
1 parent d517807 commit 5acd526
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rootfs/etc/haproxy/template/haproxy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 5acd526

Please sign in to comment.