CoreOS Cluster DNS setup

clustercoreosdomain-name-system

I'm unsure of how to setup DNS for a coreos cluster.

Currently I have all of my api instances behind a haproxy load balancer and a DNS A record which points to the (elastic) ip of the load balancer. So I can send traffic to api.myapp.com and it gets routed to an api instance. This works fine but obviously the load balancer is a single point of failure.

If I move into setting up a cluster using coreos and the cluster is running multiple services-not just the api service- how do I point api.myapp.com to the cluster in the same way as I do currently, but ensure that any requests sent using this address are somehow routed only to the api service inside the cluster? This is something not clear to me from reading many tutorials on coreos.

Best Answer

You'll need to run a routing layer (HAproxy should work fine) that is directing traffic based on HTTP host header. Run this routing container on a few machines bound to 80/443 as desired. Add A records for each of your services that point to these few machines. Your LB is now highly available.

Next, set up your HAproxy routing rules to consume the location of your downstream services and route traffic appropriately. For example, a request to api.example.com gets routed to either 10.10.10.1, 10.10.10.2 or 10.10.10.3. The router (10.10.10.1:443) sees it has two backend containers responsible for api.example.com running on 10.10.10.99:9999 and 10.10.10.98:9898. The traffic is routed to one of the containers and the request is fulfilled.

A full example of this with Vulcan proxy and etcd is here: https://coreos.com/blog/zero-downtime-frontend-deploys-vulcand/

Related Topic