Reading from etcd
Reading a value in an etcd cluster
Prerequisites
- Install
etcdctl
Procedure
Use the get subcommand to read from etcd:
1. $ etcdctl --endpoints=$ENDPOINTS get foo
2. foo
3. Hello World!
4. $
where:
foois the requested keyHello World!is the retrieved value
Or, for formatted output:
1. $ etcdctl --endpoints=$ENDPOINTS --write-out="json" get foo
2. {"header":{"cluster_id":289318470931837780,"member_id":14947050114012957595,"revision":3,"raft_term":4,
3. "kvs":[{"key":"Zm9v","create_revision":2,"mod_revision":3,"version":2,"value":"SGVsbG8gV29ybGQh"}]}}
4. $
where write-out="json" causes the value to be output in JSON format (note that the key is not returned).
Last modified June 24, 2025: etcd-website: reorganised tutorials to tasks (b5f1df7)
