etcdctl(1)
Control plane for etcd, a distributed key-value store for managing cluster configuration and service discovery.
Synopsis
etcdctl [OPTIONS] COMMAND [ARGS]...Description
etcdctl is the command-line client for etcd, a strongly consistent, distributed key-value store used by Kubernetes and other distributed systems. It allows you to read, write, and manage keys in etcd clusters, perform transactions, and manage cluster membership and leases.
Most etcdctl commands require specifying endpoints (the etcd servers to connect to). By default it tries localhost:2379, but for remote or multi-node clusters you must specify endpoints explicitly via flags or the ETCDCTL_ENDPOINTS environment variable.
Common options
| Flag | What it does |
|---|---|
--endpoints | comma-separated list of etcd server endpoints (default: http://localhost:2379) |
--cacert | path to client TLS CA certificate file for server verification |
--cert | path to client TLS certificate file for client authentication |
--key | path to client TLS key file for client authentication |
--user | username for basic authentication in user:password format |
--password | password for basic authentication (prompts if not supplied) |
--dial-timeout | timeout for dialing etcd servers (default: 2s) |
--command-timeout | timeout for each command execution (default: 5s) |
--write-out | output format: simple, json, protobuf, or table (default: simple) |
--hex | print byte strings as hex-encoded values |
Examples
Write a key-value pair to etcd; creates or overwrites the key 'mykey' with the value 'Hello World'
etcdctl --endpoints=localhost:2379 put mykey 'Hello World'Read and display the value of 'mykey' from etcd
etcdctl --endpoints=localhost:2379 get mykeyRetrieve all keys that start with '/app/' prefix, useful for listing keys in a namespace
etcdctl --endpoints=localhost:2379 get --prefix /app/List all members (nodes) in a multi-node etcd cluster
etcdctl --endpoints=node1:2379,node2:2379,node3:2379 member listDelete the key 'mykey' from etcd
etcdctl --endpoints=localhost:2379 del mykeyGet all keys with prefix in JSON format and parse with jq for detailed inspection
etcdctl --endpoints=localhost:2379 get --write-out=json /myprefix --prefix | jq .Watch for any changes to keys under '/config/' prefix in real-time
etcdctl --endpoints=localhost:2379 watch --prefix /config/Start an interactive transaction for atomic multi-step operations
etcdctl --endpoints=localhost:2379 txn --interactive