Using Consul to Track All REST Endpoints

Requirement: 5 different back-end applications displaying REST endpoints. New applications are emerging that will reveal new new endpoints. Need the ability to deploy these apps so that new endpoints are automatically registered .. and some kind of ui website that will list all endpoints in the cluster.

We are evaluating consul.io and I am not sure if this would fit well.

I went through the consular tutorial and I am confused about the concept of service registration.

How do I register a RESTful endpoint when an application server comes up? Also, if app1 wants to know the exact endpoint address opened with app2, can app1 ask the consul for that?

Any other git repos to check out?

PS. applications are built on a playback platform.

+3


source to share


2 answers


Let your applications register with the consul agent when they go online. You can use this consul api call for this .

When app2 is registered, application 1 can query the consul dns service or the consul api to get the app2 endpoint address.

Note that when using the DNS feature, application2 will only be displayed if the application is marked healthy (all logged checks for this host and service are marked as transfer).



If you want to use api calls you have more parameters.

  • This will call all services with the specified name, not the service credentials in the account. (but if the host is offline, the service will not be listed)
  • This will call all services with the specified name along with their healthchecks status. If you add "pass" to the URL, then only useful services will be displayed (for example, using the dns option).
+3


source


The problem (and solution) is well explained in Jeff's article Automatically Declaring a Docker Service with a Registrar . So if your services are Docker-ised you should use gliderlabs / registrator to automatically register / unregister services as they come in and go and then look them up in consul. Here's a complete guide on how to do this.



0


source







All Articles