Setting Up Configuration Management with Consul KV

Configuration drift between environments leads to failures after every release and long investigations. We set up Consul KV turnkey: a single configuration store, clear access policies, and a change management process. We reduce the time required to approve edits and eliminate discrepancies between environments.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

Consul KV as a single source of configuration: what breaks

While service settings live in three places — in the image, in environment variables on the host, and in edits made manually during incident triage — the source of truth becomes whoever last logged into the server.

If a container is recreated after an update, the service comes up with a different connection limit or dependency address. This is not reproducible in staging: the discrepancy surfaces several hours later under real load, when the cause is already lost among the changes.

The second class of failures is configuration drift between environments. A parameter was fixed in the test environment and not carried over to production: checks are green, but in production there is a different timeout and a different quota for external requests.

It is more dangerous when values that routing or storage access depends on diverge: some services silently go to the wrong database, and this looks like random read errors rather than a configuration problem.

The third is no history or consistency of application. It is impossible to answer who changed a value and when, so rollback is done from memory.

The update is also not atomic: some replicas have reread the configuration, others continue running with the old one, and two versions of settings live in one cluster at the same time. Diagnostics run into which node the request landed on.

A single source of configuration closes all three causes at once: centralized service configuration is stored in Consul KV, changes are versioned and explicitly tied to the environment, and application becomes manageable. We break down how this is arranged and what pitfalls await with sloppy adoption.

What centralized service configuration provides

When settings live in files on every machine, any change turns into a tour of the server fleet: some nodes received the new value, some run on the old one, and the discrepancy surfaces only in a failure.

Centralized configuration management removes this class of tasks: the value lives in one place, and services subscribe to their key prefix. The storage here is HashiCorp Consul.

The time to release changes is reduced by subscribing to a key: the service rereads the setting without restarting and without rebuilding the image.

A parameter edit is made separately from a code release — the value changes in the storage, and the application picks it up within a second. In practice, this turns hours of approvals and rollout into one verifiable operation.

The reduction in the number of failures comes not from writing the value itself, but from access rights and versioning. Rights are granted by prefixes: a service reads and changes only its own keys, so an error in one service does not rewrite other services' settings.

A unified configuration for environments is built on the same set of keys — environments differ in values, not structure, and the discrepancy between environments disappears.

Recovery time is determined by rollback speed. Every key change is recorded with a version number, so returning to the previous value is one operation instead of searching for the edit in file history.

The share of failures related to configuration drift goes to zero, and incident analysis starts with the change log, not with manually polling machines.

Configuration storage approaches: comparison

Settings can be kept in three places, and the choice between them determines how much time passes from edit to application and what happens during rollback. These are files in the repository next to the code, files directly on servers, and a managed key-value storage. Each has its own class of failures, and the approaches do not substitute well for each other.

The repository provides edit history and review, but a setting reaches the service only together with a deployment. Files on servers work while there are only a few machines and turn into configuration drift as the fleet grows.

The storage delivers changes without a rebuild, but requires a separate environment, access separation, and backups.

Option When it fits Limitations
Settings in the repository Configuration changes together with a release; history and review are needed An edit requires a rebuild and deployment; secrets settle in history
Files on servers Few machines, parameters are static Drift between nodes, no versioning, manual edits
Environment variables Parameters are tied to the launch environment No history, large configuration trees are unreadable, depend on the runtime
Key-value storage There are many settings, they change often and by different teams Requires its own environment, access, audit, backups, and secret protection

In practice, this is rarely either-or: static parameters remain next to the code, environment variables tie the service to the environment, and frequently changing values move to the storage. Next, we break down how work with Consul KV is arranged and what such a move provides.

Implementation stages: from configuration audit to handover

Consul KV adoption begins not with installation, but with a configuration audit: until it is clear which parameters are set where and who changes them, any key tree will be arbitrary and will sprawl within a month.

Therefore, the work proceeds in sequential stages, and each is closed by an artifact that you accept together with us.

  1. Inventory. We collect environment variables, configuration files, deployment scripts, and values hardcoded directly in code — with mapping to environments.
  2. Configuration audit. We divide parameters into secrets, shared service, and application-specific, mark duplicates, discrepancies between environments, and everything edited manually.
  3. Key tree schema design. We fix the hierarchy "environment → service → component", naming rules, and the order of value inheritance.
  4. Settings migration. We place values according to the designed schema, while the previous source remains operational until correctness is confirmed.
  5. Access setup. We grant services and engineers separate read and write rights so that editing production parameters is a deliberate action.
  6. Verification. We run the environment, compare service behavior before and after, and rehearse returning to previous settings.
  7. Handover. We provide the key tree description, change regulations, and on-call shift training.

Key tree, access policies, and change regulations

After Consul KV is configured, the project retains not a set of keys but a working system: with it, a new engineer brings up an environment without calls with the author, and the on-call engineer understands what to change and where. We hand over and maintain the following artifacts.

  • Key tree — a namespace schema, a naming convention like service/environment/parameter, and a rule: what lives in the common root and what is overridden in an environment.
  • Access policies — roles tied to prefixes: read for services, write only for the delivery pipeline, a separate environment for secrets.
  • Configuration templates — blanks for typical services so that a new component takes parameters by template rather than by copying someone else's block.
  • Change regulations — who initiates an edit, which values require a second approver, and which the on-call engineer changes themselves.
  • Rollback procedure — value versioning and instructions on how to return the previous set of parameters in a targeted way, without restarting the entire environment.
  • On-call instructions — scenarios for typical failures: a parameter was not applied, a service does not see a branch, access was denied by policy.
  • Edit audit — a log of KV accesses and alerts for critical prefixes so that a change does not go unnoticed.

Artifacts live next to the code and are updated with it — the tree, policies, and templates do not diverge from reality after the next release.

Case: eliminating configuration drift between environments

Before

Three environments — development, pre-production, and production — and a dozen services, each with its own configuration files laid out on servers by hand. Editing one parameter took an evening: connect to every machine, change, restart, verify.

Discrepancies between environments caused failures: configuration in pre-production is one thing, in production another, and the cause surfaced only after deployment.

What changed

We consolidated parameters into a single storage, Consul KV — one point of truth for all environments.

Configuration files are assembled from it when a service starts, and differences between environments are described explicitly: common keys are inherited, environment-specific ones are overridden at the environment level.

Every change is verified and enters version history — you can see who changed what and when, and there is somewhere to roll back to.

After

Editing a parameter takes minutes instead of an evening: one key changes, and other services pick it up themselves.

In the quarter before the transition, more than half of deployment failures were due to configuration mismatch — now such failures are gone, because discrepancies are visible before release, not in production.

Downtime during planned changes decreased from hours to restarting one service, and returning to the previous settings version is one step.

How is Consul KV different from configuration in a repository?

These are two different classes of storage, not interchangeable options. Configuration in a repository is an immutable artifact: a value passes review and enters the environment with a release.

Consul KV is a live storage of runtime values: the application reads a parameter at startup or subscribes to changes via long polling of the agent.

Hence the difference in application speed. An edit in the repository is a commit, check, build, and rollout; for a single threshold, that is minutes or more.

A write to KV reaches subscribers in fractions of a second, without rebuilding and restarting the service, so an emergency edit of a limit or service address is done on the fly.

Versioning is arranged differently. The repository provides full history, authorship, and rollback with one command.

In KV there is a modify index and a check-and-set write, which protects against concurrent edits, but there is no value history — it is kept manually: state snapshots, key duplication, or export to the repository on every write.

Access and secrets are the most noticeable difference. In a repository, rights are granted by the version control system, but a password that gets into history remains there forever.

In KV, access is separated by ACL policies on prefixes: a service receives a token only to read its key branch. At the same time, values in KV are stored in plaintext — a separate secrets storage is kept for passwords and keys, while KV stores parameters and references to them.

The choice here is not either-or, but and: immutable settings live in the repository, mutable ones in KV.

Technical questions about configuration storage

Parameter storage is a shared point of failure: if a service does not receive its settings at startup, it does not come up.

Below are answers to the questions engineers ask most often before moving a project to Consul KV from HashiCorp: prefix schema, rights, and rollout order depend on them.

What happens if the storage becomes unavailable?

The agent keeps a local copy of the required keys and serves it to the service even when the cluster is unavailable, and several nodes in different zones survive the loss of some of them.

A cold start without such a copy is the only failure scenario, so the agent should be next to the application, and parameters should not be requested over the network on every launch.

How to separate access to parameters?

Rights are granted per key prefix: a service reads only its own branches, while write remains with the branch owner. Tokens are tied to a role and have a lifetime, and changes enter the log — you can see who changed a value and when. A shared "super token" in environment variables is not needed.

How to roll back an unsuccessful change?

Edits go through the repository and automated checks, and the storage receives an already approved state — rollback comes down to returning the previous file revision. State snapshots return the entire set of keys if an edit affected several services.

What are the limitations of the approach?

A KV storage does not replace a database: large volumes, binary files, and frequent writes are not suitable for it. Consistency between keys is ensured by the application, so we keep related parameters in one key. Secrets remain in a separate storage, and KV holds a reference to them.

We cover the remaining doubts — about compatibility and the migration order for a working project — below.

Let's discuss the task: we'll review your configuration schema

For the implementation estimate to be substantive and the work plan feasible, we need your configuration schema: where services currently get parameters and how changes reach the production environment.

Below is a list of what is enough to describe in words or send as files and diagrams: exports, screenshots, and short notes will do.

  • Current configuration sources: files on servers, environment variables, templates, custom scripts — and which of these are already moved to a shared storage.
  • A list of services and environments to move to Consul KV, noting which parameters are shared and which are unique to an environment.
  • How changes are delivered now: who makes them, how long the path to the production environment takes, and where discrepancies between environments most often arise.
  • Work with secrets: where passwords and keys are stored, who has access to them, and whether Consul KV needs to be linked to a separate secrets storage.
  • Access policies: which services and teams read or change values, and whether a change log with the author of the edit is needed.
  • Rollback scenario: how you return the previous configuration, in what time, and what happens to running services during this.
  • Operational constraints: change windows, requirements for cluster fault tolerance, and connections between sites.

Describe the task in a convenient form — we will come back with an estimate and work plan: stages, scope of changes, and what will be required from your side at each step.