etcd3env provides a wrapper around a given process that will populate its environment variables from a given etcd server using the etcd v3 API.
You can just download the binary from the command line:
- Linux
curl -sL https://github.com/trackmaven/etcd3env/releases/download/v1.0.0/etcd3env-linux-amd64-1.0.0 > etcd3envIf you would prefer compile the binary (assuming buildtools and Go are installed) :
git clone [email protected]:trackmaven/etcd3env.git cd etcd3env go get github.com/tools/godep GOPATH=`pwd`/Godeps/_workspace go build -o etcd3env .| Option | Default | Description |
|---|---|---|
server, s | http://127.0.0.1:4001 | Location of the etcd server |
namespace, n | /environments/production | Etcd directory where the environment variables are fetched. You can watch multiple namespaces by using a comma-separated list (/environments/production,/environments/global) |
shutdown-behaviour, b | exit | Strategy to apply when the process exit, further information into the next paragraph |
restart:etcd3envrerun the command when the wrapped process exitsexit: Theetcd3envprocess exits with the same exit status as the wrapped process. This is likely the best choice for Kubernetes services, as they will be automatically restarted.
The CLI interface supports all of the options detailed above.
Assuming an etcd v3 server is running with a /env/test/ prefix set:
etcd3env --server http://172.31.0.1:2379 --namespace /env/test/ bash [N 180222 14:06:41 context.go:46] Connected to server: [http://172.31.0.1:2379] $ printenv