3

Requirement : 5 different internal apps exposing REST endpoints. More applications are coming which would expose further new endpoints. Need the ability when these apps are deployed, for the new endpoints to auto register.. and some kind of a web ui which would list all the endpoints in the cluster.

We are evaluating consul.io, and I am not sure if this would be a good fit for the requirement.

I went through the consul tutorial, and I am confused on the concept of service registration.

How would one register a RESTful endpoint when the app server comes up ? Also if app1 wants to know the exact endpoint address exposed by app2, would app1 be able to query consul for that ?

Any other git repo to checkout ?

PS. applications are built on play framework.

hackmabrain
  • 457
  • 1
  • 6
  • 21

2 Answers2

3

Let your apps register themselves with the consul agent when they come online. To achieve this, you can make use of this consul api call.

When app2 is registred, app1 can query the consul dns service or the consul api to get the endpoint address of app2.

Note that when making use of the DNS functionality, app2 will only show up if the app is marked as healthy (all registred checks for that host and service are marked as passing).

If you want to make use of the api calls you have more options.

  • This call will fetch all services with the specified name, not taking the healthcheck of the services in account. (but if the host is offline, the service will not be listed)
  • This call will fetch all services with the specified name along with the status of their healthchecks. If you add "?passing" to the url then only the healthy services will be displayed (like using the dns option).
Brrrr
  • 4,318
  • 4
  • 31
  • 30
  • Thank you very much, Your thoughts are inline with what I was able cipher from the docs yesterday. I am working on a POC, and will keep thread posted if the solutions seems feasible. – hackmabrain May 22 '15 at 17:28
0

The problem (and a solution) is nicely explained in Jeff's article Automatic Docker Service Announcement with Registrator. In summary, if your services are Docker-ised, you'd use gliderlabs/registrator to auto-register/de-register services as they come and go, and then look them up in Consul. Here's a complete tutorial on how this can be done.

milan
  • 11,872
  • 3
  • 42
  • 49