etcdctl

etcd 键值存储命令行客户端

补充说明

etcdctl 连接 etcd 集群读写键值、查看成员和健康状态、管理租约与快照。Kubernetes 的集群状态就存在 etcd 里,操作前必须确认目标集群和备份。

常用示例

etcdctl --endpoints=https://127.0.0.1:2379 endpoint health
etcdctl --endpoints=https://10.0.0.1:2379,https://10.0.0.2:2379 endpoint status -w table
etcdctl member list -w table
etcdctl put /app/config '{"debug":false}'
etcdctl get /app/config
etcdctl get /app/ --prefix --keys-only
etcdctl del /app/config
etcdctl watch /app/ --prefix
etcdctl lease grant 3600
etcdctl compact 12345
etcdctl defrag --endpoints=https://127.0.0.1:2379
etcdctl snapshot save /backup/etcd-$(date +%F).db

TLS 集群:

etcdctl \
  --endpoints=https://10.0.0.1:2379 \
  --cacert=/etc/etcd/ca.crt \
  --cert=/etc/etcd/client.crt \
  --key=/etc/etcd/client.key \
  endpoint health

易错点与排错

相关命令