Register a Service with Consul Service Discovery Flashcards
One of the major use cases for Consul is service discovery. Consul provides a _ that downstream services can use to _ of their upstream dependencies.
DNS interface
find the IP addresses
Consul knows where these services are located because _.
each service registers with its local Consul client
You can register services either _, which is the most common way to register services, or by making _.
by providing a service definition
a call to the HTTP API
Consul loads all configuration files in the _, so a common convention on Unix systems is to name the directory something like
configuration directory
/etc/consul.d
Consul can register services that _. It correlates each running service with its registration based on the service’s port.
aren’t running yet
If you wanted to register multiple services, you could create multiple _ in the Consul _.
service definition files
configuration directory
Once the agent adds the service to Consul’s service catalog you can query it using either the _ or _.
DNS interface
HTTP API
The DNS name for a service registered with Consul is _ , whereNAMEis _
NAME.service.consul
the name you used to register the service
The fully-qualified domain name of the web service isweb.service.consul. Query the DNS interface (which Consul runs by default on port8600) for the registered service.
dig @127.0.0.1 -p 8600 web.service.consul
Filter your HTTP API query to look for only healthy instances.
curl ‘http://localhost:8500/v1/health/service/web?passing
You can update service definitions without any downtime by changing _ and sending a_to the agent or running_.
the service definition file
SIGHUP
consul reload
The ‘check’ stanza of this service definition adds a _ that tries to _ every _.
script-based health check
connect to the web service
10 seconds via curl
If the command exits with an exit code >= 2, then the check will _. An exit code of 1 will be considered as _
fail and Consul will consider the service unhealthy
warning state.
Now reload Consul’s configuration to make it aware of the new health check.
consul reload
Consul’s DNS server only returns _
healthy results.