I’m trying to use the new Service Discovery feature available in HAProxy 1.8 as described here:
I have HAProxy sitting in front of a collection of backend servers (which are Docker containers running on ECS) that are auto-scaled in and out during the day. I’ve got a Route53 private hosted zone with an SRV record and associated A records for the live instances to facilitate discovery.
$ dig -t srv _api._tcp.test-service.internal +additional
;; ANSWER SECTION:
_api._tcp.test-service.internal. 60 IN SRV 1 1 8080 i-XXXXXXXXXXXXXXXXX.test-service.internal.
What I’m not sure about is how to configure HAProxy for this. It seems like I need a combination of server-template, and resolvers, but I can’t get it to work. Here’s what I have so far:
resolvers awsdns
nameserver dns0 "${SERVICE_DISCOVERY_DNS_SERVER0}"
nameserver dns1 "${SERVICE_DISCOVERY_DNS_SERVER1}"
nameserver dns2 "${SERVICE_DISCOVERY_DNS_SERVER2}"
nameserver dns3 "${SERVICE_DISCOVERY_DNS_SERVER3}"
backend api
option tcp-check
server-template api 5 "_api._tcp.${SERVICE_DISCOVERY_DOMAIN_NAME}" 8080 resolvers awsdns resolve-prefer ipv4
But this doesn’t work. I suspect the server-template I have above is wrong somehow. Anyone have any working examples of DNS Service Discovery that can share their configs?
Thanks in advance!
BP