Skip to content

Commit

Permalink
Merge pull request #285 from jcmoraisjr/jm-resolver-named-port
Browse files Browse the repository at this point in the history
Use SRV records on dns resolver if backend port isn’t a valid number
  • Loading branch information
jcmoraisjr authored Jan 23, 2019
2 parents 6a53df1 + 5acd526 commit 3304fe2
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 @@ -158,7 +158,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 3304fe2

Please sign in to comment.