We use progrium/registrator
and yaronr/skydns
(SkyDNS2) to publish information about Docker containers to DNS via A and SRV records. All nodes runs skydns and registrator, and first three nodes are inserted as NS-s into Route53 DNS for services.cluster-name.domain.io
. Note, v4 registrator must be used until registrator/124 is resolved.
$ host -t srv mysql-1.services.deis.r53.acp.io deis-6-1.eu.r53.acp.io
Using domain server:
Name: deis-6-1.eu.r53.acp.io
Address: 54.171.239.227#53
Aliases:
mysql-1.services.deis.r53.acp.io has SRV record 10 100 49153 ec2-54-171-239-227.eu-west-1.compute.amazonaws.com.
10
is priority, 100
is weight, 49153
is MySQL port.
The DNS name is either the Docker image (default) or could be set via SERVICE_NAME env var, see mysql-1.service
.
You can ask for internal per-container IP of Flannel network by using internal zone:
$ host -t a mathics.internal.services.deis-7.containers.r53.acp.io deis-7-1.eu.r53.acp.io
Using domain server:
Name: deis-7-1.eu.r53.acp.io
Address: 54.154.28.131#53
Aliases:
mathics.internal.services.deis-7.containers.r53.acp.io has address 10.42.47.29
mathics.internal.services.deis-7.containers.r53.acp.io has address 10.42.47.30
mathics.internal.services.deis-7.containers.r53.acp.io has address 10.42.12.21
Thus communicating with services deployed via Fleet/etc. is possible on well-known ports, without digging into SRV records or using Kubernetes env vars.
Also note, an A query to *.internal.services
will return all IP addresses handling the service, while a query to *.services
will return a CNAME to *.compute.amazonaws.com
in round-robin fashion, which in turn will resolve to VPC IP address when queried inside the AWS, and public IP addresses outside of it. Asking for SRV record will always return all hosts:
$ host -t srv skydns-53.services.deis-8.containers.r53.acp.io ec2-54-154-44-145.eu-west-1.compute.amazonaws.com
Using domain server:
Name: ec2-54-154-44-145.eu-west-1.compute.amazonaws.com
Address: 54.154.44.145#53
Aliases:
skydns-53.services.deis-8.containers.r53.acp.io has SRV record 10 33 53 ec2-54-154-44-36.eu-west-1.compute.amazonaws.com.
skydns-53.services.deis-8.containers.r53.acp.io has SRV record 10 33 53 ec2-54-154-44-145.eu-west-1.compute.amazonaws.com.
skydns-53.services.deis-8.containers.r53.acp.io has SRV record 10 33 53 ec2-54-154-44-144.eu-west-1.compute.amazonaws.com.
Note the internal
zone SRV format is different:
$ host -t srv skydns-53.internal.services.deis-8.containers.r53.acp.io ec2-54-154-44-145.eu-west-1.compute.amazonaws.com
;; Truncated, retrying in TCP mode.
Using domain server:
Name: ec2-54-154-44-145.eu-west-1.compute.amazonaws.com
Address: 54.154.44.145#53
Aliases:
skydns-53.internal.services.deis-8.containers.r53.acp.io has SRV record 10 33 53 ip-10-21-1-134.eu-west-1.compute.internal:skydns:53.skydns-53.internal.services.deis-8.containers.r53.acp.io.
skydns-53.internal.services.deis-8.containers.r53.acp.io has SRV record 10 33 53 ip-10-21-2-103.eu-west-1.compute.internal:skydns:53.skydns-53.internal.services.deis-8.containers.r53.acp.io.
skydns-53.internal.services.deis-8.containers.r53.acp.io has SRV record 10 33 53 ip-10-21-2-102.eu-west-1.compute.internal:skydns:53.skydns-53.internal.services.deis-8.containers.r53.acp.io.