On the road again

The article contains some basic commands to check Kubernetes` etcd health and performance.

Etcd is a distributed reliable key-value store for the most critical data of a distributed system. For example, it is used in Kubernetes as shown on the diagram:


We can obtain etcd CLI binary from k8s pod:
$kubectl -n kube-system get pod -o wide -l component=etcd
$kubectl -n kube-system cp etcd-master:/usr/local/bin/etcdctl-3.2.18 .
$chmod +x etcdctl-3.2.18
$sudo cp etcdctl-3.2.18 /usr/local/bin/etcdctl
Since etcdctl command requires a lot of arguments let`s create an alias:
$alias ctl8="ETCDCTL_API=3 etcdctl --endpoints= \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
Some basic commands:
$ctl8 version
$ctl8 member list
$ctl8 endpoint status
$ctl8 cluster-health
Check performance:
$ctl8 check perf
Create a snapshot:
$ctl8 snapshot save snap1.etcdb​
View snapshot info:
$ctl8 --write-out=table snapshot status snap1.etcdb​
Query etcd:
$ctl8 get --prefix --keys-only /registry/services​

Get top-level keys:

$ctl8 ls /
$ctl8 ls / --recursive

Create new directory:

$ctl8 mkdir /example

Create key and value:

$ctl8 mk /example/key data

To change the value of an existing key, or to create a key if it does not exist, use the "set" command:

$ctl8 set /example/key new
Добавить комментарий