A safe place to experiment with etcd distributed key value store.
This is a safe workspace and playground open to anyone looking to experiment with etcd distributed key value store. The environment targets dev/test usage and is not adviced to be used in production.
The workspace depneds on:
"etcd is an open-source distributed key value store that provides shared configuration and service discovery for Container Linux clusters. etcd runs on each machine in a cluster and gracefully handles leader election during network partitions and the loss of the current leader"ref.
$ direnv allow
Initialization will create the '${PWD}/bin/' folder and will download any required binaries e.g etcd, goreman etc.
Below there are some very basic tasks you may need to test against.
$ etcd
2018-12-22 21:37:52.042182 I | etcdmain: etcd Version: ...
$ goreman start
goreman start git:(master↓5↑2|✚2…
21:28:50 etcd2 | Starting etcd2 on port 5001
21:28:50 proxy | Starting proxy on port 5003
21:28:50 etcd1 | Starting etcd1 on port 5000
21:28:50 etcd3 | Starting etcd3 on port 5002
...
NOTE: by default a three node cluster is spawn please advice procfile
$ curl -L http://127.0.0.1:2379/health
member 8211f1d0f64f3269 is healthy: got healthy result from http://127.0.0.1:3379
member 91bc3c398fb3c146 is healthy: got healthy result from http://127.0.0.1:4379
member fd422379fda50e48 is healthy: got healthy result from http://127.0.0.1:5379
$ etcdctl member list
8211f1d0f64f3269: name=infra1 peerURLs=http://127.0.0.1:12380 clientURLs=http://127.0.0.1:3379 isLeader=false
91bc3c398fb3c146: name=infra2 peerURLs=http://127.0.0.1:22380 clientURLs=http://127.0.0.1:4379 isLeader=false
fd422379fda50e48: name=infra3 peerURLs=http://127.0.0.1:32380 clientURLs=http://127.0.0.1:5379 isLeader=true
$ etcdctl cluster-health
$ etcdctl set /key1 "value1"
value1
$ etcdctl get /key1
value1
etcdctl rm /key1
$ curl -L -X PUT http://127.0.0.1:2379/v2/keys/key2 -d value="value2"
$ curl -L http://127.0.0.1:2379/v2/keys/key2
{"action":"get","node":{"key":"/key2","value":"value2","modifiedIndex":19,"createdIndex":19}}
$ etcdctl mkdir /tdir
$ etcdctl ls
/tdir
$ etcdctl mk /timedkey "It's going to expire in 30 sec" --ttl 30
Check afer a couple seconds and after 30 seconds using the command below:
$ etcdctl get /timedkey "It's going to expire in 30 sec" --ttl 30