Cloud Native 16 min read

How to Set Up an etcd Cluster and Deploy It on Kubernetes

This guide walks through installing etcd, launching a static three‑node pseudo‑cluster on a single host, explains key command‑line flags, and shows how to deploy, configure, and scale the etcd cluster in Kubernetes using a corrected StatefulSet manifest.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
How to Set Up an etcd Cluster and Deploy It on Kubernetes

After briefly introducing etcd concepts, the article explains three mechanisms for starting an etcd cluster and focuses on the static method.

It shows how to install etcd binaries on a CentOS7 machine, then provides commands to launch a three‑node pseudo‑cluster on a single host, followed by etcdctl commands to check health and status.

$ wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz
$ tar -xvf etcd-v3.4.13-linux-amd64.tar.gz
$ mkdir /tmp/etcd
$ mv etcd-v3.4.13-linux-amd64/etcd /tmp/etcd/
$ mv etcd-v3.4.13-linux-amd64/etcdctl /tmp/etcd/

Next, it details the most common command‑line flags (e.g., --name , --data-dir , --listen-peer-urls , etc.) with defaults, environment variables and explanations.

The guide then describes deploying the cluster in Kubernetes using a StatefulSet, including the required Service, PodDisruptionBudget, and a corrected statefulset.yaml that replaces domain‑based URLs with IP‑based ones via the Downward API.

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: etcd
spec:
  replicas: 3
  selector:
    matchLabels:
      app: etcd
  serviceName: etcd
  template:
    metadata:
      labels:
        app: etcd
    spec:
      containers:
      - name: etcd
        image: cnych/etcd:v3.4.13
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        command:
        - /bin/sh
        - -ec
        - |
          HOSTNAME=$(hostname)
          ... (remaining script omitted for brevity) ...

It provides the full YAML manifest, shows how to apply the resources, verify the cluster status, and perform scaling up to five replicas and scaling down back to three, confirming that the cluster remains healthy.

Finally, it notes that the StatefulSet requires three 1 GiB ReadWriteOnce PersistentVolumes.

Distributed SystemsKubernetesDevOpsClusterStatefulSetetcd
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.