day1: Intro to etcd
Source: Dev.to
Introduction
Day 1 of the Kubernetes CKA study journey focuses on etcd – the key‑value store that backs the entire cluster.
What is etcd?
etcd is a highly available, distributed, and reliable key‑value database that is simple, secure, and fast. Kubernetes stores all cluster information (nodes, pods, configurations, secrets, service accounts, roles, role bindings, etc.) in etcd. Whenever you run a command like kubectl get, the API server queries the etcd database.
Because etcd is a key‑value store, it excels at quick look‑ups and retrievals. While it doesn’t support complex SQL‑style queries, the value associated with a key can be a complex data structure, such as a JSON document.
etcd Service and Client
When an etcd server starts, it listens on the server’s IP address, defaulting to port 2379. Clients connect to this endpoint to store and retrieve data. The default CLI client is etcdctl.
# Example etcdctl command
./etcdctl put key1 value1
Note: Different etcd versions expose different APIs, so the available
etcdctlcommands and verbs may vary.
etcd in Kubernetes
Every change made in a Kubernetes cluster is considered complete only after the etcd server is updated. Kubernetes stores its data in a hierarchical directory structure, with a root registry directory followed by subdirectories for each object type.
Deployment Options
- Manual installation: When building a cluster from scratch, you must download the etcd binary and run it on the master/control‑plane node.
- kubeadm: Using
kubeadmautomatically deploys etcd as a pod in thekube-systemnamespace.
High‑Availability Setup
In a high‑availability (HA) environment, multiple master/control‑plane nodes run their own etcd instances. These instances must be aware of each other, which is configured via the --initial-cluster flag in the etcd.service file, e.g.:
--initial-cluster controller1=https://10.0.0.1:2380,controller2=https://10.0.0.2:2380,controller3=https://10.0.0.3:2380
CNCF Graduation
etcd entered CNCF incubation in 2018 and graduated to a top‑level project in November 2020.