> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction to Consul KV Store

> The Consul Key/Value Store is a centralized repository for storing configuration parameters, metadata, and arbitrary data objects with high availability and fault tolerance.

The Consul Key/Value (KV) Store is a centralized repository for storing configuration parameters, metadata, and arbitrary data objects. Built into Consul, it’s always enabled and ready for use, although leveraging it remains optional. Data is replicated across all server nodes—voters, non-voters, and read replicas—ensuring high availability and fault tolerance.

<Frame>
  ![The image is an informational slide about a centralized Key/Value store, explaining its features and use cases, particularly in storing configuration parameters and metadata. It highlights its distributed architecture, installation with Consul, and accessibility by server and client agents.](https://kodekloud.com/kk-media/image/upload/v1752877777/notes-assets/images/HashiCorp-Certified-Consul-Associate-Certification-Introduction-to-Consul-KV-Store/centralized-key-value-store-features.jpg)
</Frame>

## Distributed Architecture and High Availability

* Replicates data across all Consul server nodes (voting, non-voting, read replicas)
* Maintains redundancy even if one or more nodes fail
* Accessible by server and client agents, as well as external clients with a valid ACL token (when ACLs are enabled)

<Callout icon="lightbulb" color="#1CB2FE">
  Consul KV Store is designed strictly for key/value operations, not as a full database or file system.
</Callout>

## What the Consul KV Store Is Not

<Frame>
  ![The image explains what a Key/Value store is not, highlighting that it is not a full-featured database, not encrypted, lacks a directory structure, and is stored in a single datacenter without replication.](https://kodekloud.com/kk-media/image/upload/v1752877778/notes-assets/images/HashiCorp-Certified-Consul-Associate-Certification-Introduction-to-Consul-KV-Store/key-value-store-not-full-database.jpg)
</Frame>

| Limitation                    | Explanation                                                            |
| ----------------------------- | ---------------------------------------------------------------------- |
| Not a full database           | Lacks complex queries and advanced features (e.g., DynamoDB)           |
| Not encrypted by default      | Stored in plaintext—use Vault for sensitive data                       |
| No directory hierarchy        | Forward slashes (`/`) in keys are part of the name, not actual folders |
| Single-datacenter replication | Replicates only within one datacenter, not across regions              |

<Callout icon="triangle-alert" color="#FF6B6B">
  Consul KV Store data is *not* encrypted by default. For secrets and sensitive information, use [HashiCorp Vault](https://www.vaultproject.io).
</Callout>

## Object Size Limitation

Each key/value object is limited to **512 KB**.

<Frame>
  ![The image provides additional information about Consul K/V, highlighting an object size limitation of 512KB and backup and recovery options using the consul snapshot save command and Consul snapshot agent for Enterprise.](https://kodekloud.com/kk-media/image/upload/v1752877779/notes-assets/images/HashiCorp-Certified-Consul-Associate-Certification-Introduction-to-Consul-KV-Store/consul-kv-size-limit-backup-recovery.jpg)
</Frame>

## Backup and Recovery

Consul supports snapshot-based backup and restore for KV data:

```bash theme={null}
# Backup all KV data
consul snapshot save backup.snap

# Restore KV data from a snapshot
consul snapshot restore backup.snap
```

In Consul Enterprise, the **Consul Snapshot Agent** provides automated, policy-driven backups.

<Callout icon="lightbulb" color="#1CB2FE">
  See the [Consul Backup and Restore guide](https://www.consul.io/docs/enterprise/snapshots) for advanced options.
</Callout>

## Designing the KV Structure

Collaborate with your teams to plan a KV hierarchy that meets current requirements and future growth.

<Frame>
  ![The image is a slide titled "Designing the K/V Structure," providing guidelines on designing a key/value structure, emphasizing collaboration, alignment with teams, and consideration of current and future use cases. It features colorful text and a pixelated design on the right side.](https://kodekloud.com/kk-media/image/upload/v1752877780/notes-assets/images/HashiCorp-Certified-Consul-Associate-Certification-Introduction-to-Consul-KV-Store/designing-kv-structure-guidelines-slide.jpg)
</Frame>

### Example 1: SDLC-Based Structure

Organize keys by environment:

* k8s/
  * dev/
  * qa/
  * staging/
  * production/

Example keys:

* `k8s/staging/app3/api-key`
* `k8s/staging/app3/certificate`

### Example 2: Team-Based Structure

Group keys by team and service:

<Frame>
  ![The image is a diagram illustrating the design of a key/value (K/V) structure based on teams, with categories like cloud, automation, data, and apps, and subcategories such as chef, aws, TFE, and app1-3. It includes specific parameters like account numbers and API keys.](https://kodekloud.com/kk-media/image/upload/v1752877782/notes-assets/images/HashiCorp-Certified-Consul-Associate-Certification-Introduction-to-Consul-KV-Store/kv-structure-diagram-teams-categories.jpg)
</Frame>

* **cloud/**
  * `cloud/aws/account-number`
  * `cloud/aws/account-name`
* **apps/**
  * `apps/app1/param1`
  * `apps/app2/param2`

Tailor your structure to align with application teams and infrastructure needs.

## Links and References

* [Consul Documentation](https://www.consul.io/docs)
* [Vault Documentation](https://www.vaultproject.io/docs)
* [Kubernetes Basics](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/)
* [Terraform Registry](https://registry.terraform.io/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/hashicorp-certified-consul-associate-certification/module/70a7eb0f-aec7-41aa-b417-398c341698b6/lesson/31a5f0ad-8329-4870-b4ae-c4fd116e3a31" />
</CardGroup>
