$linuxjunkies
>

etcdctl(1)

Control plane for etcd, a distributed key-value store for managing cluster configuration and service discovery.

UbuntuDebianFedoraArch

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

FlagWhat it does
--endpointscomma-separated list of etcd server endpoints (default: http://localhost:2379)
--cacertpath to client TLS CA certificate file for server verification
--certpath to client TLS certificate file for client authentication
--keypath to client TLS key file for client authentication
--userusername for basic authentication in user:password format
--passwordpassword for basic authentication (prompts if not supplied)
--dial-timeouttimeout for dialing etcd servers (default: 2s)
--command-timeouttimeout for each command execution (default: 5s)
--write-outoutput format: simple, json, protobuf, or table (default: simple)
--hexprint 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 mykey

Retrieve 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 list

Delete the key 'mykey' from etcd

etcdctl --endpoints=localhost:2379 del mykey

Get 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

Related commands