Skip to content

Instantly share code, notes, and snippets.

@philips
Last active December 30, 2015 18:19
Show Gist options
  • Select an option

  • Save philips/7866706 to your computer and use it in GitHub Desktop.

Select an option

Save philips/7866706 to your computer and use it in GitHub Desktop.

This is a temporary workaround to have a customized etcd configuration.

Create a local state directory

sudo mkdir /media/state/overlays/var/lib/etcd-local
sudo chown etcd:etcd /media/state/overlays/var/lib/etcd-local

Add a local etcd unit file

Create a file called /media/state/units/etcd-local.service that has the following contents:

NOTE: You need to substitute the other cluster members into the $OTHER_CLUSTER_IPS variable in this file. Also the 127.0.0.1 addresses should change to your actual public IP if you want to cluster over the internet.

[Unit]
Description=etcd local

[Service]
User=etcd
PermissionsStartOnly=true
ExecStartPre=/usr/bin/systemctl kill etcd.service
ExecStart=/usr/bin/etcd -name myhost -data-dir /var/lib/etcd-local -bind-addr 0.0.0.0 -addr 127.0.0.1:4001 -peer-bind-addr 0.0.0.0 -peer-addr 127.0.0.1:7001 -peers $OTHER_CLUSTER_IPS

Restart=always
# Set a longish timeout in case this machine isn't behaving
# nicely and bothering the rest of the cluster
RestartSec=10s

[Install]
WantedBy=local.target

Bootstrap the first node

To bootstrap the cluster run one node manually in an ssh session like so sudo -u etcd /usr/bin/etcd -name myhost -data-dir /var/lib/etcd-local -bind-addr 0.0.0.0 -addr 127.0.0.1:4001 -peer-bind-addr 0.0.0.0 -peer-addr 127.0.0.1:7001 then start the other two machines via systemctl as outlined before.

Enable the local etcd

sudo systemctl restart local-enable.service

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment