etcdctl Cheatsheet
etcdctl Cheatsheet
This etcdctl cheatsheet provides essential commands and deployment instructions for managing etcd, a distributed key-value store used in Kubernetes. Use this guide to quickly deploy, manage, and interact with your etcd cluster.
Deployment
Deploy with Kubernetes:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install default-etcd bitnami/etcd --set auth.rbac.create=False --set replicaCount=3 --namespace kube-system
To create a pod that you can use as an etcd client, run the following command:
kubectl run default-etcd-client --restart='Never' --image docker.io/bitnami/etcd:3.5.9-debian-11-r146 --env ETCDCTL_ENDPOINTS="default-etcd.kube-system.svc.cluster.local:2379" --namespace kube-system --command -- sleep infinity
Exec into the client pod:
kubectl exec --namespace kube-system -it default-etcd-client -- bash
Commands
List members:
etcdctl member list --write-out=table
Write a value to a key:
etcdctl put /message Hello
View a key's value:
etcdctl get /message
Same as above, but only view the value:
etcdctl get /message --print-value-only
View all the keys:
etcdctl get "" --prefix --keys-only
View the key and values:
etcdctl get "" --prefix
Return the value only
Resources
More cheatsheets: