Custom mulitple health checks with docker-consul

186 views
Skip to first unread message

Shakthi Kannan

unread,
May 7, 2015, 8:35:35 AM5/7/15
to consu...@googlegroups.com
Hi,

I would like to add custom /etc/consul.d/*.json checks and monitor the
same using consul.

I followed the documentation under "Testing a Consul cluster on a
single host" from:

https://github.com/progrium/docker-consul

and was able to start two containers - one running as server and
another as client, and was able to join the client with the server. To
start the server, I used the following:

$ sudo docker run --name consul -p 8400:8400 -p 8500:8500 -p
8600:53/udp -v "/home/guest/mnt:/data" -h consul progrium/consul
-server -bootstrap -ui-dir /ui

$ JOIN_IP="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' consul)"

I started the consul-client using the following:

$ sudo docker run --name consul-client -v
"/home/guest/consul.d:/etc/consul.d" progrium/consul -join $JOIN_IP

I see the following output in the server log:

...
2015/05/07 12:30:38 [INFO] consul: member 'e3f2648568ee' joined,
marking health alive
...

I added the following simple JSON in /home/guest/consul.d/

{"check": {"name": "Ping test", "script": "ping -c3 www.google.com
>/dev/null", "interval": "60s"}}

I see two nodes in the consul UI dashboard, but, not the 'Ping test'
service check. What could I be missing?

Appreciate any help in this regard,

Thanks!

SK

--
Shakthi Kannan
http://www.shakthimaan.com

Armon Dadgar

unread,
May 7, 2015, 9:19:52 PM5/7/15
to consu...@googlegroups.com, Shakthi Kannan
Hey Shakthi,

Consul does not automatically pickup changes to the configuration in its
configuration directory. You can either issue a “consul reload” or send it a
SIGHUP to force it to update the configuration files.

Additionally, Consul does not watch any directories for configuration by
default. You can provide those via “-config-dir=/etc/consul.d/“.

Hope that helps!

Best Regards,
Armon Dadgar
--
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shakthi Kannan

unread,
May 8, 2015, 12:25:14 AM5/8/15
to Armon Dadgar, consu...@googlegroups.com
Hi Armon,

--- On Fri, May 8, 2015 at 6:48 AM, Armon Dadgar <armon....@gmail.com> wrote:
| Consul does not automatically pickup changes to the configuration in its
| configuration directory. You can either issue a “consul reload” or send it a
| SIGHUP to force it to update the configuration files.
\--

Sorry, how do I send it a SIGHUP?

---
| Additionally, Consul does not watch any directories for configuration by
| default. You can provide those via “-config-dir=/etc/consul.d/“.
\--

Please CMIIW. I am able to attach to the running consul-client container using:

$ sudo docker exec -i -t bd8 bash

I see the following processes running:

bash-4.3# ps -ae | grep consul
1 root /bin/consul agent -config-dir=/config -join 172.17.0.21
27 root grep consul

How do I stop the currently running agent? And then I should issue the
following?

bash-4.3# mkdir /etc/consul.d

bash-4.3# echo '{"check": {"name": "Ping test", "script": "ping -c3
www.google.com
> >/dev/null", "interval": "60s"}}' > /etc/consul.d/ping.json

bash-4.3# consul agent -config-dir=/etc/consul.d -join 172.17.0.21

Thanks for your prompt response,

Shakthi Kannan

unread,
May 8, 2015, 2:53:16 AM5/8/15
to Armon Dadgar, consu...@googlegroups.com
Hi,

I logged into the consul-client and added .json files in /config.

$ sudo docker exec -i -t container-id bash

I was then able to send a SIGHUP using:

$ sudo docker kill -s SIGHUP container-id

This reloaded the configuration and picked up the new service checks.

I want to be able to start many consul-client containers, but, they
need to use the JSON health check files from localhost (not /config
inside the container). I tried the following:

$ sudo docker run --name consul-client -v
"/home/guest/consul.d:/config" progrium/consul -join $JOIN_IP
==> Must specify data directory using -data-dir

This -data-dir is required by consul agent. How can I specify the same
through docker?
Reply all
Reply to author
Forward
0 new messages