Project: etcd (Orchestration & Management / Coordination & Service Discovery)
File: READMEv2.md

etcdctl ======== `etcdctl` is a command line client for . It can be used in scripts or for administrators to explore an etcd cluster. The latest release is available as a binary at along with etcd. etcdctl can also be built from source using the build script found in the parent directory. output cURL commands which can be used to reproduce the request don't synchronize cluster information before sending request Use this to access non-published client endpoints Without this flag, values from `--endpoint` flag will be overwritten by etcd cluster when it does internal sync. output response in the given format (`simple`, `extended` or `json`) default: `"simple"` domain name to query for SRV records describing cluster endpoints default: none env variable: ETCDCTLDISCOVERYSRV a comma-delimited list of machine addresses in the cluster default: `"http://127.0.0.1:2379"` env variable: ETCDCTL_PEERS a comma-delimited list of machine addresses in the cluster default: `"http://127.0.0.1:2379"` env variable: ETCDCTL_ENDPOINT Without `--no-sync` flag, this will be overwritten by etcd cluster when it does internal

identify HTTPS client using this SSL certificate file default: none env variable: ETCDCTLCERTFILE identify HTTPS client using this SSL key file default: none env variable: ETCDCTLKEYFILE verify certificates of HTTPS-enabled servers using this CA bundle default: none env variable: ETCDCTLCAFILE provide username[:password] and prompt if password is not supplied default: none env variable: ETCDCTL_USERNAME connection timeout per request default: `"1s"` timeout for the command execution (except watch) default: `"5s"` Set a value on the `/foo/bar` key: ```sh $ etcdctl set /foo/bar "Hello world" Hello world ``` Set a value on the `/foo/bar` key with a value that expires in 60 seconds: ```sh $ etcdctl set /foo/bar "Hello world" --ttl 60 Hello world ``` Conditionally set a value on `/foo/bar` if the previous value was "Hello world": ```sh $ etcdctl set /foo/bar "Goodbye world" --swap-with-value "Hello world" Goodbye world ``` Conditionally set a value on `/foo/bar` if the previous etcd index was 12: ```sh $ etcdctl set /foo/bar "Goodbye world" --swap-with-index 12 Goodbye world ``` Create a new key `/foo/bar`, only if the key did not previously exist: ```sh $ etcdctl mk /foo/new_bar "Hello world" Hello world ``` Create a new in-order key under dir `/fooDir`: ```sh $ etcdctl mk --in-order /fooDir "Hello world" ``` Create a new dir `/fooDir`, only if the key did not previously exist: ```sh $ etcdctl mkdir /fooDir ``` Update an existing key `/foo/bar`, only if the key already existed: ```sh $ etcdctl update /foo/bar "Hola mundo" Hola mundo ``` Create or update a directory called `/mydir`: ```sh $ etcdctl setdir /mydir ``` Get the current value for a single key in the local etcd node: ```sh $ etcdctl get /foo/bar Hello world ``` Get the value of a key with additional metadata in a parseable format: ```sh $ etcdctl -o extended get /foo/bar Key: /foo/bar Modified-Index: 72 TTL: 0 Etcd-Index: 72 Raft-Index: 5611 Raft-Term: 1 Hello World ``` Explore the keyspace using the `ls` command ```sh $ etcdctl ls /akey /adir $ etcdctl ls /adir /adir/key1 /adir/key2 ``` Add `--recursive` to recursively list subdirectories encountered. ```sh $ etcdctl ls --recursive /akey /adir /adir/key1 /adir/key2 ``` Directories can also have a trailing `/` added to output using `-p`. ```sh $ etcdctl ls -p /akey /adir/ ``` Delete a key: ```sh $ etcdctl rm /foo/bar ``` Delete an empty directory or a key-value pair ```sh $ etcdctl rmdir /path/to/dir ``` or ```sh $ etcdctl rm /path/to/dir --dir ``` Recursively delete a key and all child keys: ```sh $ etcdctl rm /path/to/dir --recursive ``` Conditionally delete `/foo/bar` if the previous value was "Hello world": ```sh $ etcdctl rm /foo/bar --with-value "Hello world" ``` Conditionally delete `/foo/bar` if the previous etcd index was 12: ```sh $ etcdctl rm /foo/bar --with-index 12 ``` Watch for only the next change on a key: ```sh $ etcdctl watch /foo/bar Hello world ``` Continuously watch a key: ```sh $ etcdctl watch /foo/bar --forever Hello world .... client hangs forever until ctrl+C printing values as key change ``` Continuously watch a key, starting with a given etcd index: ```sh $ etcdctl watch /foo/bar --forever --index 12 Hello world .... client hangs forever until ctrl+C printing values as key change ``` Continuously watch a key and exec a program: ```sh $ etcdctl exec-watch /foo/bar -- sh -c "env | grep ETCD" ETCDWATCHACTION=set ETCDWATCHVALUE=My configuration stuff ETCDWATCHMODIFIED_INDEX=1999 ETCDWATCHKEY=/foo/bar ETCDWATCHACTION=set ETCDWATCHVALUE=My new configuration stuff ETCDWATCHMODIFIED_INDEX=2000 ETCDWATCHKEY=/foo/bar ``` Continuously and recursively watch a key and exec a program: ```sh $ etcdctl exec-watch --recursive /foo -- sh -c "env | grep ETCD" ETCDWATCHACTION=set ETCDWATCHVALUE=My configuration stuff ETCDWATCHMODIFIED_INDEX=1999 ETCDWATCHKEY=/foo/bar ETCDWATCHACTION=set ETCDWATCHVALUE=My new configuration stuff ETCDWATCHMODIFIED_INDEX=2000 ETCDWATCHKEY=/foo/barbar ``` The following exit