Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

ETCD

etcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.

Kubeadm defaults to running a single member etcd cluster in a static pod managed by the kubelet on the control plane node. This is not a high availability setup as the etcd cluster contains only one member and cannot sustain any members becoming unavailable.

Find the pod that it's running etcd:

export ETCD_POD=$(kubectl get pods -n kube-system -o wide | grep etcd | awk '{print $1}')

Save the pod IP in an environment variable:

export ENDPOINT=$(kubectl get pods -n kube-system -o wide | grep etcd | awk '{print $6}')

Run the etcdctl command from inside one of those pods to retrieve the etcd version running

kubectl -n kube-system exec $ETCD_POD -- sh -c "etcdctl version"

Check the etcd configuration located in etc/kubernetes/manifests/etcd.yaml:

cat /etc/kubernetes/manifests/etcd.yaml

Common etcd commands

See the status:

ETCDCTL_API=3 sudo etcdctl endpoint status \
    --endpoints=https://$ENDPOINT:2379 \
    --cacert=/etc/kubernetes/pki/etcd/ca.crt \
    --cert=/etc/kubernetes/pki/etcd/server.crt \
    --key=/etc/kubernetes/pki/etcd/server.key \
    --write-out=table 

List the members ot etcd cluster:

ETCDCTL_API=3 sudo etcdctl member list \
    --endpoints=https://$ENDPOINT:2379 \
    --cacert=/etc/kubernetes/pki/etcd/ca.crt \
    --cert=/etc/kubernetes/pki/etcd/server.crt \
    --key=/etc/kubernetes/pki/etcd/server.key \
    --write-out=table 

Backup etcd cluster:

ETCDCTL_API=3 sudo etcdctl snapshot save my_snapshot \
    --endpoints=https://$ENDPOINT:2379 \
    --cacert=/etc/kubernetes/pki/etcd/ca.crt \
    --cert=/etc/kubernetes/pki/etcd/server.crt \
    --key=/etc/kubernetes/pki/etcd/server.key 

See the status of the snapshot:

ETCDCTL_API=3 sudo etcdctl snapshot status my_snapshot \
    --endpoints=https://$ENDPOINT:2379 \
    --cacert=/etc/kubernetes/pki/etcd/ca.crt \
    --cert=/etc/kubernetes/pki/etcd/server.crt \
    --key=/etc/kubernetes/pki/etcd/server.key \
    --write-out=table 

To eventually restore etcd cluster:

ETCDCTL_API=3 sudo etcdctl snapshot restore my_snapshot \
    --endpoints=https://$ENDPOINT:2379 \
    --cacert=/etc/kubernetes/pki/etcd/ca.crt \
    --cert=/etc/kubernetes/pki/etcd/server.crt \
    --key=/etc/kubernetes/pki/etcd/server.key