ETCD
What is ETCD?
etcd is a distributed, consistent, highly-available key-value store used to store critical cluster data.
It is a core component of Kubernetes.
etcd port : 2379
Why ETCD Is Important
In Kubernetes, etcd stores the entire cluster state, including:
-
Nodes
-
Pods
-
Services
-
ConfigMaps
-
Secrets
-
Deployments
-
RBAC policies
If etcd goes down → the cluster control plane stops functioning.
ETCD Architecture
etcd is based on:
-
Distributed consensus algorithm: Raft
-
Leader–Follower model
-
Strong consistency
High-Level Architecture
───────────────┐
│ ETCD Leader │
└───────┬───────┘
│
┌─────────┴─────────┐
│ │
┌───────────────┐ ┌───────────────┐
│ ETCD Follower │ │ ETCD Follower │
└───────────────┘ └───────────────┘
How Kubernetes Uses ETCD
kubectl apply → API Server → etcd
- User sends request
- API Server validates
- State stored in etcd
- Controllers reconcile state
ETCD Data Storage
-
Data stored as key-value pairs
-
Hierarchical structure
Example keys in Kubernetes:
/registry/pods/default/nginx
/registry/services/default/my-service
ETCD Deployment in Kubernetes
Single Master (Not Recommended for Production)
Master Node
├── kube-apiserver
├── kube-controller-manager
├── kube-scheduler
└── etcd
HA Multi-Master (Production)
Master 1 ─┐
Master 2 ─┼── etcd Cluster (3 or 5 nodes)
Master 3 ─┘
Best practice:
-
3 or 5 etcd members
Odd number only (quorum)
Important ETCD Ports
| Port | Purpose |
|---|---|
| 2379 | Client communication |
| 2380 | Peer communication |
ETCD Commands
Using etcdctl CLI:
Check Cluster Health
etcdctl endpoint health
List Membersetcdctl member list
Get Key
etcdctl get /registry/pods --prefix
Put Key
etcdctl put mykey "value"
Backup ETCD (Very Important in Production)
Take Snapshot
etcdctl snapshot save snapshot.db
Installing ETCD as a service
✅ 1️⃣ Download etcd
Official binaries are available from the etcd GitHub releases.
Comments
Post a Comment