Skip to content

Consul Service Registration#

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure. It’s often used as service discovery backend to register and locate the services composing your system. Consul makes it simple for services to register themselves and to discover other services via a DNS or HTTP interface. External services can be registered as well.

This page explains how Stork can use Consul to handle the service registration.

Dependency#

First, you need to add the Stork Consul Service Registration provider:

<dependency>
    <groupId>io.smallrye.stork</groupId>
    <artifactId>stork-service-registration-consul</artifactId>
    <version>2.7.4</version>
</dependency>

Service registration configuration#

For each service that should register the service instances in Consul, configure the service registrar type:

stork.my-service.service-registrar.type=consul
quarkus.stork.my-service.service-registrar.type=consul

Consul service registrar is configured with the following parameters:

Attribute Mandatory Default Value Description
consul-host No localhost The Consul host.
consul-port No 8500 The Consul port.
health-check-url No `` The liveness http address.
health-check-interval No 30s How often Consul performs the health check
health-check-deregister-after No 1m How long after the check is in critical status Consul will remove the service from the catalogue.

Service deregistration configuration#

There is no specific configuration required to enable deregistration; however, you must ensure that a consul service registrar is configured for the service:

stork.my-service.service-registrar.type=consul
quarkus.stork.my-service.service-registrar.type=consul

As with registration, deregistration relies on the service name.