Skip to main content

ETCD (Distributed reliable Key-Value Store)

https://github.com/etcd-io/etcd

As mentioned earlier, ETCD is a store for keeping key-value pairs in a:

  • Secure
  • Fast
  • Simple

way.

When a SQL database adds a new entry to a table, not all information is filled in. A new column would impact the addition of this information for all entries (rows) in the table.

Alt text

In a key-value store like ETCD, it would look like this.

Alt text

All information for an entry is kept together in a single key-value table, and a new entry doesn't impact others. YAML and JSON can represent these tables in a very simple way.

Installation

To install, just download the binary, extract and run.

curl -L https://github.com/etcd-io/etcd/releases/download/v3.5.11/etcd-v3.5.11-linux-amd64.tar.gz -o etcd-v3.5.11-linux-amd64.tar.gz
tar xzvf etcd-v3.5.11-linux-amd64.tar.gz
tar - xzvf
cd etcd-v3.5.11-linux-amd64
./etcd
....#Removed
94d","cluster-version":"3.5"}
{"level":"info","ts":"2023-12-22T19:55:41.701034-0300","caller":"api/capability.go:75","msg":"enabled capabilities for version","cluster-version":"3.5"}
{"level":"info","ts":"2023-12-22T19:55:41.701049-0300","caller":"etcdserver/server.go:2599","msg":"cluster version is updated","cluster-version":"3.5"}
{"level":"info","ts":"2023-12-22T19:55:41.701228-0300","caller":"embed/serve.go:187","msg":"serving client traffic insecurely; this is strongly discouraged!","traffic":"grpc+http","address":"127.0.0.1:2379"} #<<<<<

It will start a service that will listen on port 2379.

Using a client we can retrieve and store information. The client that comes with the package is etcdctl.

./etcdctl version
etcdctl version: 3.5.11
API version: 3.5
➜ ./etcdctl put key1 value1
OK
➜ ./etcdctl get key1
key1
value1

If you want to install etcdctl on an Ubuntu machine, we can install the package.

sudo apt-get install etcd-client

ETCD in Kubernetes

It's used to store information about nodes, pods, configs, secrets, accounts, roles, bindings, etc. All information that the Kube-APIServer manages is stored in ETCD, meaning if we lose ETCD, the entire cluster is lost.

Only after the information is updated in ETCD is a cluster change considered complete.

Usually ETCD ends up being placed together with the control plane nodes when we configure the cluster using kubeadm, but ETCD can be a service separate from Kubernetes. During the course we'll learn how to configure a cluster with external ETCD in high availability.