Vault CSI provider examples
The following examples demonstrate how the Vault CSI Provider can be used.
A common mistake is to not install the CSI Secret Store Driver before using the Vault CSI Provider.
File based dynamic database credentials
The following Secret Provider Class retrieves dynamic database credentials from Vault and extracts the generated username and password. The secrets are then mounted as files in the configured mount location.
Next, a pod can be created to use this Secret Provider Class to populate the secrets in the pod:
The pod mounts a CSI volume and specifies the Secret Provider Class (vault-db-creds
) created above.
The secrets created from that provider class are mounted to /mnt/secrets-store
. When this pod is
created the containers will find two files containing secrets:
Environment variable dynamic database credentials
The following Secret Provider Class retrieves dynamic database credentials from Vault and extracts the generated username and password. The secrets are then synced to Kubernetes secrets so that they can be mounted as environment variables in the containers.
Next, a pod can be created which uses this Secret Provider Class to populate the secrets in the pod's environment:
The pod mounts a CSI volume and specifies the Secret Provider Class (vault-db-creds
) created above.
The secrets created from that provider class are mounted to /mnt/secrets-store
, additionally a Kubernetes
secret called vault-db-creds
is created and referenced in two environment variables.