When building clusters that can dynamically change, you need to be able to discover when new servers come and old servers go. Brightbox cloud servers can look up their own server group membership details using our metadata service but not those of other servers. Our API allows you to get (and of course change) the membership details of any of your server groups, but rigging that up is often overkill.
We launched a simple little feature last week that offers a lightweight
alternative this that is natively supported pretty much everywhere: Server
groups can now be resolved using DNS and returns the IPs
for all the members of the group. Just look up the group identifier with the
region domain name (e.g: grp-xxxxx.gb1.brightbox.com
):
$ host grp-k2axk.gb1.brightbox.com
grp-k2axk.gb1.brightbox.com has address 10.242.101.114
grp-k2axk.gb1.brightbox.com has address 10.242.44.206
grp-k2axk.gb1.brightbox.com has IPv6 address 2a02:1348:17c:8b33:24:19ff:fef2:2cce
grp-k2axk.gb1.brightbox.com has IPv6 address 2a02:1348:17c:995c:24:19ff:fef2:6572
When you add or remove a server from the group, its A and AAAA records are added or removed from the domain name automatically. It has a TTL of 60 seconds so changes become visible within a minute.
So, for example, if you configure NGINX to use this new group domain name as a backend proxy destination NGINX will add all the servers in the group as separate backends and balance requests between them. You can then just build new app servers, add them to the group and NGINX will start using them automatically:
server {
listen 80 default_server;
listen [::]:80 default_server;
resolver 10.242.x.x;
location / {
set $backend_upstream "http://grp-k2axk.gb1.brightbox.com:80";
proxy_pass $backend_upstream;
}
}
Note that for this to work properly, you need to specify a resolver
(each
cloud server has an upstream resolver available on its default gateway) and the
proxy_pass
directive needs to use a variable (otherwise NGINX won’t keep looking it up).
NGINX will default to rechecking the DNS after the TTL expires, but you can tweak that setting (and others) if you wish.
For software that doesn’t directly support this kind of behaviour, you could put together a script to write a config out and reload it when the DNS record changes (or use config management software to do that, such as Puppet or Ansible).
You can get just the IPv6 addresses using ipv6.grp-k2axk.gb1.brightbox.com
and
you can get just the publicly routable IP addresses (that is the IPv6 and any
mapped Cloud IPv4 addresses) using public.grp-k2axk.gb1.brightbox.com
.
And remember, there are several other convenient DNS records available for your cloud servers and cloud IPs. See the reference documentation for more details.