--- layout: docs page_title: Migrate Consul to Raft storage description: >- Guide to migration of Consul storage to Raft. --- # Migrate Consul to Raft storage This procedure assumes you have a Vault cluster deployed in a Kubernetes environment configured with Consul storage. The storage migration can occur while leaving the Consul cluster intact. A single change to the Consul cluster is a lock file written by Vault during the migration. This guide uses basic examples and default Vault configurations. It is for illustrative purposes, and adaption to specific configurations relevant to your environment is still required. Always back up your data before attempting migration! Although this is an offline operation and the risk is low, it is advisable to take a recent snapshot from your Consul cluster before proceeding. ## Overview This guide uses an intermediate Helm configuration to introduce an init container that will perform the storage migration, and then start a single Vault server using the Raft storage backend to verify the results. Then update the Helm configuration to remove the init container and start Vault replicas. ### Vault and Kubernetes setup Consider the following `vault status` output and Helm Chart values for Vault: ```plaintext Key Value --- ----- Seal Type shamir Initialized true Sealed false Total Shares 1 Threshold 1 Version 1.14.8+ent Build Date 2023-12-05T01:49:39Z Storage Type consul Cluster Name vault-cluster-68870bf8 Cluster ID cd18c692-f2e3-77a5-fba3-28f06f41f375 HA Enabled true HA Cluster https://vault-0.vault-internal:8201 HA Mode active Active Since 2024-04-10T02:45:33.367042122Z Last WAL 52 ``` Helm chart values: ```plaintext global: enabled: false server: enabled: true image: repository: hashicorp/vault-enterprise tag: 1.14.8-ent enterpriseLicense: secretName: vault-license secretKey: vault.hclic ha: enabled: true replicas: 3 config: | ui = true service_registration "kubernetes" {} listener "tcp" { address = ":8200" cluster_address = ":8201" tls_disable = 1 } storage "consul" { path = "vault" address = "http://HOST_IP:8500" } ``` ### Migration procedure 1. Uninstall Vault via Helm. ```shell-session $ helm uninstall vault ``` Deployed `StatefulSets` cannot have certain attributes modified after their initial deployment. Therefore, the `StatefulSet` deployment must be entirely replaced. Vault servers using Consul storage are by default stateless. Unless explicitly configured, the Vault server `StatefulSet` does not create any Persistent Volume Claims (PVC) or other artifacts. Vault's index holds its state, which is entirely stored in the Consul server `StatefulSet`'s persistent volumes. It is strongly advised to review your Vault deployment configurations and take appropriate backups for any stateful information managed via Helm or other orchestration platforms. 1. Create a `ConfigMap` containing the Storage Migration configuration. ```shell-session $ cat > vault-storage-migration-configmap.yml < vault-migration-values.yml < vault-raft-values.yml < ```she-session $ kubectl exec -it vault-0 -- vault status Key Value --- ----- Seal Type shamir Initialized true Sealed false Total Shares 1 Threshold 1 Version 1.14.8+ent Build Date 2023-12-05T01:49:39Z Storage Type consul Cluster Name vault-cluster-68870bf8 Cluster ID cd18c692-f2e3-77a5-fba3-28f06f41f375 HA Enabled true HA Cluster https://vault-0.vault-internal:8201 HA Mode active Active Since 2024-04-10T04:44:12.516016652Z Last WAL 54 ``` ## References - [Vault operator migrate command](/vault/docs/commands/operator/migrate) - [Helm Chart configuration](/vault/docs/platform/k8s/helm/configuration) - [Vault on Kubernetes deployment guide](/vault/tutorials/kubernetes/kubernetes-raft-deployment-guide) - [Vault Helm Chart configuration](https://github.com/hashicorp/vault-helm) - [kubectl commands](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands) - [Kubernetes storage volumes](https://kubernetes.io/docs/concepts/storage/volumes/) - [Create a Pod that has an Init Container](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/#create-a-pod-that-has-an-init-container) - [Helm docs](https://helm.sh/docs/)