Consul
Dynamically configure applications
This topic provides an overview for dynamically configuring applications when Consul detects certain changes in your network. Many of these operations rely on Consul's key/value (KV)store.
For information about automatically deploying infrastructure when Consul detects failed health checks or increased network traffic, refer to Consul-Terraform-Sync.
Introduction
Platform operators managing a Consul deployment at scale require automated processes for generating and distributing updated configurations dynamically as applications change. You can use Consul's KV store to store data for generating Consul agent configurations, and set up the agent to invoke custom scripts in response to changes.
Key/value store
Consul includes a built-in key/value store that stores indexed objects on Consul servers and makes them accessible by any Consul agent. Advanced deployment strategies leverage Consul's KV store to watch for changes, create distributed semaphors, and dynamically generate configuration files for automated deployments. Consul's KV store is enabled by default. The Consul KV API, CLI, and UI are now considered feature complete and no new feature development is planned for future releases.
For more information, refer to Consul key/value (KV) store overview.
Sessions
Consul provides a session mechanism you can use to build distributed locks. When the services in an application's service mesh operate across multiple nodes, distributed locks can restrict traffic between nodes to prevent resource exhaustion and application failure. Sessions can be configured to use data from Consul's KV store.
For more information, refer to Sessions overview.
Watches
Watches can monitor a datacenter's key/value (KV) store, services, nodes, health checks, and events for updates. You can configure a view of data to watch in an agent configuration file so that when the data changes, Consul invokes a handler that can call an HTTP endpoint or run an executable.
For more information, refer to Watches overview.
Consul template
Consul Template is a tool that enables you to programmatically render configuration files according to data in Consul's KV store and the services registered to the catalog. It updates configuration files according to relevant changes in the datacenter. This tool requires a separate download and installation becuase it is not part of Consul's binary.
For more information, refer to Consul Template overview.
Network infrastructure automation
Network Infrastructure Automation (NIA) enables dynamic updates to network infrastructure devices triggered by service changes. Consul-Terraform-Sync (CTS) utilizes Consul as a data source that contains networking information about services and monitors those services. Terraform is used as the underlying automation tool and leverages the Terraform provider ecosystem to drive relevant changes to the network infrastructure.
Consul-Terraform-Sync requires an Enterprise license. For more information, refer to Network infrastructure automation.
Guidance
To learn how to dynamically configure applications using Consul's KV store, complete the tutorials in the Integrate your Applications with Consul collection.
Reference documentation
The most experienced users want to quickly find the reference information for specific parts of the component they are using. List all relevant reference pages for the topic.
Constraints, limitations, and troubleshooting
If you experience errors when using the Consul KV store, refer to the following list of technical constraints.
- The Consul KV and its API, CLI, and UI controls are considered feature complete. New feature development is not planned for future Consul releases.