25 points · by fjolliton · 10y ago · 13 comments
For example, a lot of apps use a hierarchical config where you can specify everything as YAML. Elasticsearch comes to mind. This works quite well because any property can be referred to as dotted keypaths, e.g. "discovery.zen.minimum_master_nodes".
Kubernetes also uses YAML/JSON structures as a configuration interface. Kubernetes supports JSON Patch [1], a poor man's patching format for editing keys deep within a document, and it also supports JSONPath [2] for templating.
But what these don't do is treat the entire config as a big tree, and I think that's a good compromise. Kubernetes stores all its config in Etcd, but this config is considered an implementation detail — you're not supposed to edit it directly — and moreover, Etcd is like a file system, not a key/value tree; Kubernetes maps each path to a file, not a single value.
I like this approach, because individual objects can be validated separately by type. Kubernetes has a schema, which each object (YAML file) declares:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: postgresql-master
This maps directly to the version of the API that changes need to go through in order to make the configuration persistent.If you try to make one huge key/value tree, you're more likely to end up with something like the Windows Registry, a huge ball of spaghetti.
Etcd is also a hierarchical database, but you can use it like a robust distributed file system. A big benefit you get is liveness; you can respond dynamically to config changes by watching for change events.
If your configuration is more than simple, then there are plenty of real dbs that implement everything explained in this article "properly".
This "tree db" is concurrent to read, not to write, doesn't bother with the hard parts of concurrency, ie. deletion of old data and uses an ad hoc json/pointer bs. system to write/read data.
The most common criticism of the Windows Registry is that it is a per-user/per-machine database stored in an opaque format, thus making it harder than necessary to manipulate or version the data for individual applications. On the other hand, this project and Augeas focus on providing means to read and manipulate text-based configuration files that ensure the file contents' integrity is preserved. They do it by parsing the text into a tree first and serializing the tree afterwards. This lets you keep your individual configuration files as small as you wish and easy enough to version and compare.