Search code examples
consul

Registering service on existing node in Consul


There is a Consul cluster in my local environment, and some developers' local machines as well. Each developer has a Tomcat server which runs some web artifacts in Docker container, so I want to register these artifacts as services on Tomcat deploy.

Assuming that we have already registered empty node for each developer's local machine, how can i register/deregister a new service on existing node? Do i need consul agent running on any node?

I know it's possible to add service when registering node, but haven't found any info about how to add services to node dynamically. I'd prefer HTTP API if possible (it's much easier to run on local machines).


Solution

  • Do i need consul agent running on any node?

    Yes, even though you can add external services to a remote machine using curl post too, the service discovery is going to benifit you with the agent running on nodes too.

    I know it's possible to add service when registering node, but haven't found any info about how to add services to node dynamically.

    Registering a service is fairly easy on consul and you can find more details at the following link: https://www.consul.io/intro/getting-started/services.html

    However, if you wish to give better isolation to your developers, I would recommend running the consul agent server/client in docker and let registrator take care of everything.

    Registrator from gliderlabs is service registry bridge for Docker. It automatically registers and deregisters services for any Docker container by inspecting containers as they come online.

    You can find more details here: https://github.com/gliderlabs/registrator