Uninstalled and Re-Installed Vault. But still says "error: Vault is already initialized"

I uninstalled vault :

root@k8s-eu-1-control-plane-node-1:~# helm uninstall -n $VAULT_K8S_NAMESPACE $VAULT_HELM_RELEASE_NAME hashicorp/vault
release "vault" uninstalled

And re-installed it via helm:

root@k8s-eu-1-control-plane-node-1:~# helm install -n $VAULT_K8S_NAMESPACE $VAULT_HELM_RELEASE_NAME hashicorp/vault -f ${WORKDIR}/overrides.yaml
NAME: vault
LAST DEPLOYED: Mon Sep  9 15:08:38 2024
NAMESPACE: vault
STATUS: deployed
REVISION: 1
NOTES:
Thank you for installing HashiCorp Vault!

root@k8s-eu-1-control-plane-node-1:~# kubectl -n $VAULT_K8S_NAMESPACE get pods
NAME                                    READY   STATUS    RESTARTS   AGE
vault-0                                 0/1     Running   0          57s
vault-1                                 0/1     Running   0          57s
vault-2                                 0/1     Running   0          57s
vault-agent-injector-588bdf8d9d-mkl99   1/1     Running   0          57s

Tried to re-initialize it but got “error: Vault is already initialized”

root@k8s-eu-1-control-plane-node-1:~# kubectl exec -n $VAULT_K8S_NAMESPACE vault-0 -- vault operator init \
>     -key-shares=3 \
>     -key-threshold=3 \
>     -format=json > ${WORKDIR}/cluster-keys.json
Error initializing: Error making API request.

URL: PUT https://127.0.0.1:8200/v1/sys/init
Code: 400. Errors:

* Vault is already initialized
command terminated with exit code 2

What else do I have to do, apart from uninstall vault, and remove /tmp/vault folder, in order to be able to initialize it again?

I think you will also need to delete storage, because state of Vault cluster is persisted in the storage.

1 Like

Yes. That was the problem

Thank you

1 Like