Azure Key Vault CSI on Azure Red Hat OpenShift
This content is authored by Red Hat experts, but has not yet been tested on every supported configuration.
This document is adapted from the Azure Key Vault CSI Walkthrough specifically to run with Azure Red Hat OpenShift (ARO).
Prerequisites
- An ARO cluster
- The AZ CLI (logged in)
- The OC CLI (logged in)
- Helm 3.x CLI
Environment Variables
Run this command to set some environment variables to use throughout
Note if you created the cluster from the instructions linked above these will re-use the same environment variables, or default them to
openshiftandeastus.
Installing the Kubernetes Secret Store CSI
Create an OpenShift Project to deploy the CSI into
Set SecurityContextConstraints to allow the CSI driver to run (otherwise the DaemonSet will not be able to create Pods)
Add the Secrets Store CSI Driver to your Helm Repositories
Update your Helm Repositories
Install the secrets store csi driver
Check that the Daemonsets is running
You should see the following
Add pod security profile label for CSI Driver
This is required starting in OpenShift v4.13
Deploy Azure Key Store CSI
Add the Azure Helm Repository
Update your local Helm Repositories
Install the Azure Key Vault CSI provider
Set SecurityContextConstraints to allow the CSI driver to run
Create Keyvault and a Secret
Create a namespace for your application
Create an Azure Keyvault in your Resource Group that contains ARO
Give your user account permissions to manage secrets in Key Vault
Replace <your-email-address> with your actual value, which is your sign-in name.
Create a secret in the Keyvault
Create a Service Principal for the key Vault
Note: If this gives you an error, you may need upgrade your Azure CLI to the latest version.
Give the Service Principal permissions to use secrets in Key Vault
Create and label a secret for Kubernetes to use to access the Key Vault
Deploy an Application that uses the CSI
Create a Secret Provider Class to give access to this secret
Create a Pod that uses the above Secret Provider Class
Check the Secret is mounted
Output should match:
Print the Secret
Output should match:
Cleanup
Uninstall Helm
Delete the app
Delete the Azure Key Vault
Delete the Service Principal
Uninstalling the Kubernetes Secret Store CSI
Delete the secrets store csi driver
Delete the SecurityContextConstraints