Prerequisites
- Vault CLI installed and configured
- A running and unsealed Vault server
- Vault Authentication set up for your environment
Ensure your Vault server is unsealed and your CLI is authenticated (
vault login) before proceeding.1. Enable the KV v2 Secrets Engine
Mount the KV v2 engine at thecrds/ path:
2. Read from an Empty Path
If no data exists atcrds/mysql, Vault returns an error:
3. Storing Secrets
3.1 Create the First Version
Store only a username:3.2 Update with a Password
Add a password to create version 2:3.3 Add an API Key
You can append fields anytime (creates version 3):4. Retrieve Secrets and Metadata
4.1 Fetch Both Data and Metadata
4.2 Fetch Only Metadata
5. Deleting Secrets
5.1 Soft Delete Latest Version
Soft-deleted versions can be undeleted until permanently destroyed. To irreversibly remove versions, use
vault kv destroy.6. Using KV Engine Inside Kubernetes
If Vault is running in Kubernetes, exec into the pod to run the same commands:After adding secrets, configure authentication methods and attach policies so applications can securely access your KV paths. See Vault Policies for more details.