Introduction to ETCD
What is ETCD?
The technical definition is: “etcd is a consistent and highly-available key value store used as Kubernetes’ backing store for all cluster data.” What does that mean, though? Let’s see if we can take a look under the hood and start with the basics.
What is a key-value store?
We most often see databases in tabular format. Which, in other words, is just data stored in rows and columns. For example, you might have a column for “Name”, and second for “Age”, a third for “Favorite food”, and so on.
A key-value store is a bit different in that you cannot have duplicate keys. In other words, there can only be one key called “Name”. Each key has an associated value.
Value: Ice cream
This is useful for storing small chunks of data that require fast read/write.
Installing and running etcd
To test out using etcd as a key-value store on your own, install it locally on a Linux machine. At the time of writing, v3.5.1 is the latest.
I used these commands to install it on a vanilla Debian server.
curl -L https://github.com/coreos/etcd/releases/download/v3.5.1/etcd-v3.5.1-linux-amd64.tar.gz -o etcd-v3.5.1-linux-amd64.tar.gz tar xzvf etcd-v3.5.1-linux-amd64.tar.gz rm etcd-v3.5.1-linux-amd64.tar.gz
etcd-v3.5.1-linux-amd64 to your PATH.
etcd to start it. This will run a service that listens or port 2379, which the
ss command shows:
$ ss -plunt | grep :2379
tcp LISTEN 0 128 127.0.0.1:2379 *:* users:(("etcd",pid=2394,fd=8))
In a new screen session (or with tmux), you can create a key-value store using etcdctl. (Note: You’ll need to export your PATH again in the new terminal window/screen/pane, unless you added it permanently to your PATH in your bash profile.)
Now you can create a key-value store using etcdctl.
$ etcdctl put name joe
To view the value associated with this key (name), run:
$ etcdctl get name