Richard Bucker

if you have etcd should everything use it?

Posted at — Mar 2, 2015

For many years after Microsoft deployed the registry it was the hell of all hells. It was the one thing that could kill your windows server or desktop and could render your machine unusable. In some cases you could boot into single user mode and repair it; years later there was a snapshot tool; and a plethora of 3rd party tools that did the same.

The etcd project from CoreOS defines etcd as “A highly-available key value store for shared configuration and service discovery”.

Talking about Service Discovery,

If you’re deploying a gaggle of applications in your environment they may need to discover each other in order to communicate on some level. This function is/was traditionally performed with a DNS server and/or configuration files. In this environment systems and services were typically static, however, in the world of containers and virtualization anything can be anywhere. And worse yet the IP address can change more frequently. High Availability(HA) and system hardware, container failures and system/application upgrades (blue/green) can make the entire system unstable.

One challenge for DNS is that it has a TTL. It takes time for records to be updated and pass through the system. On the other hand the TTL can be set very low for frequent updates and more importantly DNS is the authority on hostname+IPaddress configurations. However in the realm of service discovery DNS is useless. DNS is essentially a key/value store where the key is the fully qualified domain name(fqdn) and the value is the IP address. Of course there are other records and other ways to search the DNS repository but in the end this is what you get.

But what happens when you take etcd and put a DNS API wrapper around it. That’s the premise behind SkyDNS. SkyDNS provides the same DNS APIs but uses etcd to store the data instead of other mediums like a traditional DNS server. This is ok for a number of reasons. First of all having direct access to etcd means that the data can be updated using standard etcd query strings. It also means that SkyDNS could implement a listener such than when records important to SkyDNS are updated SkyDNS is given a poke so that it can figure out what happened and react.

The big benefit for this model is that the storage and replication is shared and can be easily backed up. Depending on what you know about DNS this could actually be good or bad. DNS replication may or may not be in realtime in the traditional sense. And in SixSigma/Root Cause analysis the notion that SkyDNS relies on etcd means that the aggregate system is inherently less reliable.

Now what is going to happen when you have 20 or 30 applications and services that use etcd in the same way you might have previously used postgres or some other replicated db? Here is the point where I leave you hanging. etcd is a replicated KV store. There are many KV stores. I’m certain etcd is small (the rocket container is 3.5MB) Fleet and flannel and possibly a few systems use etcd for configuration management so it’s clear that it works. But where is the line? Should it be orchestration configuration management or just any kind of configuration?

etcd does not support TLS yet. So security is going to be a hack for a while. What else is missing?

PS: If I had to deploy a DNS server right now I’d probably go with GeoDNS. It has a good reputation and is used by the NTP project. I’m pretty certain that it uses a config file instead of a database for the configuration. This also make replication simple. It also puts the burden on the application and the filesystem to replicate and slide the new configuration in. I do not see it here but I imagine that storing the configuration in a VCS repo and triggering changes would be very useful. As for services it’s time to start looking at the extended attributes.