Debian - Install Etcd

About Etcd

etcd is an open-source distributed key value store that provides shared configuration and service discovery. We are interested in using etcd as it is one of the supported discovery service backends supported by Docker in order to deploy a docker swarm (cluster). Alternative backends include consul and zookeeper.

Installation

Navigate to the releases page of etcd. At the time of writing this post, the latest version is 2.2.2 and installation is as simple as:

sudo apt-get install curl -y
curl -L  https://github.com/coreos/etcd/releases/download/v2.2.2/etcd-v2.2.2-linux-amd64.tar.gz -o etcd-v2.2.2-linux-amd64.tar.gz
tar xzvf etcd-v2.2.2-linux-amd64.tar.gz
rm etcd-v2.2.2-linux-amd64.tar.gz

Now to start the etcd process, execute:

cd etcd-v2.2.2-linux-amd64
./etcd

You may want to just add the etcd binary to your $PATH

Example Usage

etcdctl set mykey "this is awesome"  
etcdctl get mykey  

You will need to execute these commands within your installation folder, or have added etcdl to your $PATH.

Running Through Docker

Etcd can be run through using docker. First install docker if you haven't already. Then execute:

docker run \
--name etcd \
quay.io/coreos/etcd:v2.2.2

Example Usage

docker exec etcd /etcdctl set foo bar
docker exec etcd /etcdctl get foo

The above example is the simplest way to get started, but there is a guide for more advanced setups through docker.

Remote Invokation using Curl

To test that your remote etcd server is listening to external requests, you can send a request from another machine with curl.

To set a value of Hello World for the key: message on the server at etcd.programster.org, you would use:

curl -L \
http://etcd.programster.org:4001/v2/keys/message \
-XPUT -d value="Hello world"

To retrieve the value for the key: message on the server at etcd.programster.org, you would use:

curl -L http://etcd.programster.org:4001/v2/keys/message

References

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus