What is ETCD?
The full form of "etcd" is derived from the Linux directory structure. In UNIX, system configuration files for a single system are stored in a folder called "/etc." The "d" in "etcd" stands for "distributed"
ETCD is a reliable key-value store that is simple, fast, and secure.
Key-value pair:
This information can be stored in any format or structure and does not affect other information, unlike databases. Updating one key-value pair does not affect other pairs. JSON or YAML can be used for the key-value pairs.
Getting started:
- Download the binaries, extract them, and run the ETCD service. By default, the service runs on port 2379.
- Any client can be added to ETCD. The default ETCD client is 'etcdctl,' which is a command-line utility for storing and retrieving key-value pairs.
Examples of using 'etcdctl':
-
To set a key-value pair: ./etcdctl set key1 pair1
-
To get the value of a key: ./etcdctl get key1
To check the ETCD version: ./etcdctl –version
ETCDCTL version: 3.3.11 API version: 2
While API version 2 is widely used, version 3.0 is also available. It is important to check the version before working with ETCD.
How to change API versions:
-
Temporary change throughout the session: ETCDCTL_API=3 ./etcdctl version
-
Persistent change using an environment variable: export ETCDCTL_API=3 ./etcdctl version
ETCDCTL version: 3.3.11 API version: 3
To store and retrieve key-value pairs using 'etcdctl':
-
To store a key-value pair: ./etcdctl put key1 pair1
-
To get the value of a key: ./etcdctl get key1
ETCD datastore stores information about:
- Nodes
- Pods
- Configs
- Secrets
- Accounts
- Roles
- Bindings
- Others
If Kubernetes (k8s) is installed from scratch, ETCD must be installed manually using the binaries and configured as a service on the master node. If kubeadm is used for installing k8s, it automatically installs ETCD as a pod in the 'kube-system' namespace. ETCD can be accessed using the following command: kubectl exec etcd-master -n kube-system etcdctl get /
In a high availability environment, multiple master nodes in a cluster have multiple ETCD clusters across them."