Consul Service Discovery#
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.
As specified in the Consul documentation, if the host address is not provided, Stork will automatically use the Consul node address for the instance.
This page explains how Stork can use Consul to handle the service discovery and service registration.
Dependency#
First, you need to add the Stork Consul Service Discovery provider:
<dependency>
<groupId>io.smallrye.stork</groupId>
<artifactId>stork-service-discovery-consul</artifactId>
<version>2.7.1</version>
</dependency>
Service discovery configuration#
For each service that should get the service instances from Consul, configure the service discovery type
:
Consul service discovery 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. |
use-health-checks |
No | true |
Whether to use health check. |
application |
No | The application name; if not defined Stork service name will be used. | |
refresh-period |
No | 5M |
Service discovery cache refresh period. |
secure |
No | whether the connection with the service should be encrypted with TLS. |