Skip to content

Instantly share code, notes, and snippets.

@tcnksm
Last active August 25, 2016 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tcnksm/43241b00c4ecf9d1e680 to your computer and use it in GitHub Desktop.
Save tcnksm/43241b00c4ecf9d1e680 to your computer and use it in GitHub Desktop.
consul memo

n1

Web UI

consul agent -server -bootstrap -data-dir /tmp/consul -ui-dir /var/consul-ui -node=agent-one -client=172.20.20.10 -bind=172.20.20.10

n2

DNS masq, http://www.morethanseven.net/2014/04/25/consul/

consul agent -data-dir /tmp/consul -node=agent-two -bind=172.20.20.11 -join=172.20.20.10

sudo apt-get install dnsmasq
sudo echo "server=/consul/127.0.0.1#8600" > /etc/dnsmasq.d/10-consul
sudo service dnsmasq restart

ping agent-one.node.consul # n1 から n2にアクセス

$ curl agent-one.node.consul:8500/v1/health/state/critical
[{"Node":"agent-three","CheckID":"service:web","Name":"Service 'web' check","Status":"critical","Notes":"","Output":"","ServiceID":"web","ServiceName":"web"}]

n3

Define service

sudo apt-get install apache2
sudo mkdir /etc/consul.d/
sudo echo '{"service": {"name": "web", "tags": ["apache"], "port": 80, "check": {"script": "curl localhost:80 >/dev/null 2>&1", "interval": "10s"}}}' >web.jso
n
$ consul agent -data-dir /tmp/consul -node=agent-three -config-dir=/etc/consul.d/ -bind=172.20.20.12 -join=172.20.20.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment