What is ETCD?
ETCD is a distributed reliable key-value store that is simple, secure and Fast. It is used to hold and manage the critical information that distributed systems need to keep running. Most commonly, it manages the configuration data, state data, and metadata for Kubernetes, the popular container orchestration platform.
What is Key-Value store
Traditionally databases have been in a tabular form. You must have heard about SQL or relational databases. They stored data in the form of rows and columns. For example
In the above table, row represents each person and column represents the type of information. Now you want add additional details like salary then we need to add additional column.
But here some persons are not working (for example students). So here some cells are empty. Now you want to add grade column for students, so you need to add new column to the existing table
Now again only students have grades and empty cells for employees. Every time new information is adding the entire table is affected and leads to lot of empty cells.
Now avoid such problems, key value store were introduced. key value stores store information in the form of documents or pages. So each individual gets a document and all information about that individual store within that file. These files can be any format or structure and changes one file doesn’t effect to another.
ETCD installation is very simple
1. Download Binaries
curl -L https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz -o /tmp/etcd-v3.4.13-linux-amd64.tar.gz
tar -xvzf /tmp/etcd-v3.4.13-linux-amd64.tar.gz
3. RUN ETCD Service
When you run the etcd, it starts a service that listen on port 2379 by default. You can then attach clients to etcd service to store and retrieve information. The default client that comes with etcd is etcdctl client.
To set information
./etcdctl set key1 value1
To set information
./etcdctl get key1 value1
ETCD in Kubernetes
The ETCD data store stores information regarding the cluster such as Nodes, PODs, Config, Secrets, Accounts, Roles, Bindings and Others. Every change you made in cluster such as adding additional nodes, deploying pods, replica sets are updated in this data store.
Only once it is updated in the ETCD server is the change considered to be complete. Depending on how you setup your cluster, ETCD is deployed differently.
It has to be a part of the Kubernetes master, or you can configure it externally as well. ETCD is written in the goLang, and it is based on the Raft consensus algorithm.
The raft allows the collection of machines to work as a coherent group that can survive the failures of some of its members. Even if some of the members fail to work, this algorithm can still work at any given time. One of the nodes in the group will be the master, and the rest of them will be the followers.