The aim of this project is to achieve a third party registration in consul for every containers deployed through rancher. Since the release of Rancher v1.2.0 and its migration to the CNI framework, registrator isn't able to see containers port mappings anymore.
Rancher-registrator relies on the docker.sock and the rancher metadata API to do its job.
Rancher-registrator is made to run in a container on each host of your infrastructure. It needs to be deployed alongside a local consul-agent to register its services.
For now, Rancher-registrator only registers its service into Consul backend. Etcd and Zookeeper aren't yet supported.
Rancher-registrator is made to be launched from Rancher. It needs to be started in networking mode "host" and with 2 rancher labels :
It also needs to be mapped on the docker.sock file of the host :
launch command
docker run -it --net=host -v /var/run/docker.sock:/var/run/docker.sock --label io.rancher.container.network=false --label io.rancher.container.dns=true --name=registrator rancher-registrator
Optional environment vars
You can set 2 environment variables :
We have ported the very basic labels offered by the original registrator :
SERVICE_NAME : Allows you to override the service name registered in consul
SERVICE_IGNORE : Set to true, it allows you to ignore the service registration.
SERVICE_TAGS: An comma-delimited list of strings used as tags in consul. (note : JSON is not allowed for now)
SERVICE_[private_port]_NAME : Allows you to declare a different service name for different ports
SERVICE_[private_port]_CHECK_HTTP : Allows you to declare an healthcheck at the same time you register your service in consul. The value of this label is the path to check. Example :
SERVICE_9000_CHECK_HTTP = /api/ping
SERVICE_[private_port]_CHECK_INTERVAL : Defines the frequency of the healthCheck. The default value is 10s.
SERVICE_[private_port]_CHECK_TIMEOUT : Defines the timeout from which the healthcheck is considered as "not passing".
This project is automatically build at this address : https://hub.docker.com/r/fmeriot/rancher-registrator/
So you can pull it with
docker pull fmeriot/rancher-registrator