Consul Template is the server that listens for changes in the consul database. On every change it is able to react. Besides that Consul Template can act as a process manager and run programs e.g. haproxy.
This container runs a consul-template which connects to the local consul agent. It also starts a haproxy on and exposes that on port 80 of the docker host. Every service registered is written to haproxy configuration through consul-template if things in the registry change.
For the services to talk to each other they use the service registry router. That is a haproxy which is configured and able to find all instances of all services and loadbalances the requests to the service containers.
Haproxy is run by consul-template and constantly updated with changes in the registry. Every request that wants to talk to a service will do so by accessing haproxy first which then routes to an instance of the requested service.
To access a Service: http://DOCKER_HOST_IP/service-name
To build a new image use the
make build
command.
Currently there are two configurations and templates. One for each service type. For each ECS Cluster a different configuration is used. This is unpleasant and should probably be fixed through proper use of the consul-template's templating features.
The Image starts the consul-template command. To run locally you have to provide volumes for /etc/haproxy and /var/run/haproxy for haproxy to work properly.
https://hub.docker.com/r/vicampo/consul/
docker build -t vicampo/consul-template-haproxy:0.3 .
docker push vicampo/consul-template-haproxy
Bitbucket: https://bitbucket.org/vicampo/consul-template-haproxy DockerHub: https://hub.docker.com/r/vicampo/consul-template-haproxy/
Altered the path of the health check in haproxy
Config Changes
Content type
Image
Digest
Size
7.9 MB
Last updated
over 5 years ago
docker pull vicampo/consul-template