Skip to content

Instantly share code, notes, and snippets.

@d-smith
Last active August 24, 2016 13:35
Show Gist options
  • Select an option

  • Save d-smith/8f3f89f570cad70f0fa0 to your computer and use it in GitHub Desktop.

Select an option

Save d-smith/8f3f89f570cad70f0fa0 to your computer and use it in GitHub Desktop.
Consul Notes
Grab the two node vagrant set up from here:
https://github.com/hashicorp/consul/tree/master/demo/vagrant-cluster
Install consul
wget https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip
Copy consul into /usr/local/bin
Run it
consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul
Run it with a directory with service definitions
1st, create /etc/consul.d
2nd, add a service defnition
sudo echo '{"service": {"name": "web", "tags": ["rails"], "port": 80}}' > /etc/consul.d/web.json
Then run it like
consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -config-dir /etc/consul.d
Note that I had to clear out /tmp/consul to get the service version to work
Some queries:
consul members
dig @127.0.0.1 -p 8600 n1.node.consul
dig @127.0.0.1 -p 8600 web.service.consul
curl localhost:8500/v1/catalog/nodes
For the web console
wget https://dl.bintray.com/mitchellh/consul/0.4.1_web_ui.zip
Unzip it, note the full path, in this case /home/vagrant/dist
Include the -web-ui argument to the agent. Also, by default clients are only
bound to 127.0.0.1, so add the -client option if that is not acceptable
consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul \
-node=agent-one -bind=172.20.20.10 -ui-dir /home/vagrant/dist/ -client 172.20.20.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment