consul
Last updated
Was this helpful?
Last updated
Was this helpful?
Grey Matter Control supports service discovery from . For a working example, see .
To discover services using Consul, there are three specifications that must be met in the Consul configuration and specified in the configuration of gm-control
.
Each service must be registered with a . The Consul Agents should be running in the same cluster. For gm-control
to recognize instance information such as node and/or service health, services should be registered with their own client node (agent). More information on running a Consul Agent can be found . The cluster should be running at a known address to be specified in the gm-control
configuration.
Consul services are collected by gm-control
from a single specified datacenter, thus all services to be discovered by Consul must be registered in this datacenter. The datacenter is a also a part of the configuration.
NOTE The datacenter must be explicitly set using the command line flag
--dc
or environment variableGM_CONTROL_CONSUL_DC
when runninggm-control
.
Services in Consul are discovered by gm-control
using tags. All services to be discovered by gm-control
must contain a matching service tag. Tags are specified in the in the form of "tags": ["{chosen-tag}"]
. Without this tag, services will be ignored by the control plane.
NOTE By default, this tag must be
"gm-cluster"
or can be otherwise specified togm-control
on the command line with the flag--cluster-tag
.
The following three environment variables must be set in gm-control
to discover services from Consul:
GM_CONTROL_CONSUL_HOSTPORT
must specify the address of your Consul cluster. As noted above, the datacenter can be specified here or with the command line flag --dc
.
There is an optional environment variable, GM_CONTROL_XDS_RESOLVE_DNS
, which should be set to true
in order to resolve service DNS before passing the instance IPs to Envoy (as service instances will normally be registered as IP addresses). If you plan to use Envoy to route to hostname, make sure to set this flag.