Skip to content

Hands-on tutorial on how to use Consul for Service Discovery

License

Notifications You must be signed in to change notification settings

santteegt/docker-consul-demo

Repository files navigation

Service Discovery using Consul

The aim of this repository is to present an hands-on tutorial on how to setup Consul as a service discovery framework. One of main advantages of Consul are its available REST API to register and query services, so it is not necessary to import extra libraries and/or dependencies to manage the communication between services.

Installation instructions

  1. Requirements
  • Docker 3.2+
  1. Run the following commands:
$ git clone <REPO_GIT_URL>
$ cd docker-consul-demo
$ docker-compose up  

How to check everything is working ?

Create and execute service queries

  • To create a sample query template, run the following command:
$ curl --request POST --data @consul.query.sample.json http://127.0.0.1:8501/v1/query >> query_id.json

In this tutorial, the query registration is made through the Microservice Sample 2

  • To Executing the prepared service query created above, copy the ID field from query_id.json file and run the following command:
$ curl --request GET http://127.0.0.1:8501/v1/query/<query-template-id>/execute

An example of query response can be seen in query_execution.sample.json file.

  • To query current available queries:
$ curl --request GET http://127.0.0.1:8501/v1/query

About

Hands-on tutorial on how to use Consul for Service Discovery

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages