
{"id":7611,"date":"2020-05-13T09:06:57","date_gmt":"2020-05-13T09:06:57","guid":{"rendered":"https:\/\/rax-stg-wp-aws.com\/blogs\/use-the-azure-secret-store-csi-driver-in-aks\/"},"modified":"2026-11-03T19:28:46","modified_gmt":"2026-11-03T19:28:46","slug":"use-the-azure-secret-store-csi-driver-in-aks","status":"publish","type":"blogs","link":"https:\/\/www.rackspace.com\/en-gb\/blogs\/use-the-azure-secret-store-csi-driver-in-aks\/","title":{"rendered":"Use the Azure Secret Store CSI driver in AKS"},"content":{"rendered":"<p>If you have been using Azure\u00ae Key Vault FlexVolume for Azure Kubernetes Service (AKS), it is&nbsp;time to switch over to the new provider. Azure deprecated the FlexVolume solution in favor of&nbsp;the <a href=\"https:\/\/github.com\/Azure\/secrets-store-csi-driver-provider-azure\">Azure Key Vault Provider for Secret Store CSI Driver<\/a>. The Azure Key Vault provider for the <a href=\"https:\/\/github.com\/kubernetes-sigs\/secrets-store-csi-driver\">Secret Store CSI driver<\/a>&nbsp;has a simple configuration that makes deployment and governance around keys, secrets, and&nbsp;certificates feel like any other Azure resource talking to the key vault. Let&#8217;s take a look&nbsp;at a complete example from provisioning an AKS cluster to reading in a secret as an environmental variable.<\/p>\n<p><strong>&nbsp;Provision infrastructure for the demo<\/strong><\/p>\n<p>Before you can pass secrets into an AKS cluster, provision a key vault and add a secret into the vault:<\/p>\n<p><em>&nbsp; &nbsp; az group create &#8211;location $location &#8211;name $kvRg&nbsp;<br \/>\n&nbsp; &nbsp; az keyvault create &#8211;location $location &#8211;name $kvName &#8211;resource-group $kvRg &#8211;enable-soft-delete $fals<\/em>e<\/p>\n<p><em>&nbsp; &nbsp; #add secret to key vault<br \/>\n&nbsp; &nbsp; $pw = [System.Web.Security.Membership]::GeneratePassword(12, 2)<br \/>\n&nbsp; &nbsp; az keyvault secret set &#8211;vault-name $kvName &#8211;name mssql-secret &#8211;value $pw<br \/>\n&nbsp; &nbsp; az keyvault secret show &#8211;name mssql-secret &#8211;vault-name $kvName<\/em><\/p>\n<p>I recommend an AKS cluster with a Kubernetes\u00ae version of 1.16.0 or greater. Configure the cluster with the following code:<\/p>\n<p>&nbsp; <em>&nbsp; az group create &#8211;name $aksRg &#8211;location $location<br \/>\n&nbsp; &nbsp; az aks create `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;resource-group $aksRg `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;name $aksName `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;node-count 1 `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;kubernetes-version 1.16.7 `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;generate-ssh-keys `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;enable-vmss `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;vm-set-type VirtualMachineScaleSets `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;load-balancer-sku standard `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;network-plugin azure `<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;&#8211;enable-managed-identity&nbsp;<\/em><\/p>\n<p>Because this process passes the <strong>&#8211;enable-managed-identity<\/strong>&nbsp;switch, you need to pull out&nbsp;the managed identity ID. Use this ID to assign the <strong>Managed Identity Operator<\/strong>&nbsp;and&nbsp;<strong>Virtual Machine Contributor<\/strong>&nbsp;role to the <em>`AKS MC_`<\/em> resource group:<\/p>\n<p><em>&nbsp; &nbsp; #get access creds for cluster<br \/>\n&nbsp; &nbsp; az aks get-credentials &#8211;resource-group $aksRg &#8211;name $aksName<\/em><\/p>\n<p><em>&nbsp; &nbsp; #get our managed identity id<br \/>\n&nbsp; &nbsp; $subscriptionId = az account show &#8211;query id &#8211;output tsv<br \/>\n&nbsp; &nbsp; $identity = az aks show -g $aksRg -n $aksName &#8211;query identityProfile.kubeletidentity.clientId -o tsv<\/em><\/p>\n<p><em>&nbsp; &nbsp; az role assignment create &#8211;role &#8220;Managed Identity Operator&#8221; &#8211;assignee $identity &#8211;scope &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#8220;\/subscriptions\/$subscriptionId\/resourcegroups\/MC_$($aksName)_$($aksName)_southcentralus&#8221;<br \/>\n&nbsp; &nbsp; az role assignment create &#8211;role &#8220;Virtual Machine Contributor&#8221; &#8211;assignee $identity &#8211;scope &#8220;\/subscriptions\/$subscriptionId\/resourcegroups\/MC_$($aksName)_$($aksName)_southcentralus&#8221;<\/em><\/p>\n<p>\nSet the access policy to allow the preceding identity to permit GET operations for keys, secrets,&nbsp;and certificates.<\/p>\n<p><em>&nbsp; &nbsp; # set policy to access keys in your Key Vault<br \/>\n&nbsp; &nbsp; az keyvault set-policy -n $kvName &#8211;key-permissions get &#8211;spn $identity<br \/>\n&nbsp; &nbsp; # set policy to access secrets in your Key Vault<br \/>\n&nbsp; &nbsp; az keyvault set-policy -n $kvName &#8211;secret-permissions get &#8211;spn $identity<br \/>\n&nbsp; &nbsp; # set policy to access certs in your Key Vault<br \/>\n&nbsp; &nbsp; az keyvault set-policy -n $kvName &#8211;certificate-permissions get &#8211;spn $identity<\/em><\/p>\n<p>Use HELM\u00ae to install the driver:<\/p>\n<p>&nbsp; <em>&nbsp; helm repo add csi-secrets-store-provider-azure https:\/\/raw.githubusercontent.com\/Azure\/secrets-store-csi-driver-provider-azure\/master\/charts<br \/>\n&nbsp; &nbsp; helm install csi-secrets-store-provider-azure\/csi-secrets-store-provider-azure &#8211;generate-name<\/em><\/p>\n<p><em>&nbsp; &nbsp; #Verify pods being created and on which specific node (linux and windows node)<br \/>\n&nbsp; &nbsp; kubectl get pods -o wide<\/em><\/p>\n<p><strong>Create a secretproviderclasses resource&nbsp;<\/strong><\/p>\n<p>Create a yml file called <strong>kv-sqldemo.yml<\/strong>&nbsp;and paste the following code. Configure the following values in <strong>secretObjects<\/strong>, <strong>objects<\/strong>&nbsp;and <strong>objectType<\/strong>&nbsp;in the yml file:&nbsp;<\/p>\n<p>\n&#8211; <strong>useVMManagedIdentity<\/strong><br \/>\n&#8211; <strong>userAssignedIdentityID<\/strong><br \/>\n&#8211; <strong>keyvaultName<\/strong><br \/>\n&#8211; <strong>secretName<\/strong><br \/>\n&#8211; <strong>key<\/strong><br \/>\n&#8211; <strong>objectName<\/strong><\/p>\n<p>\nBecause you provisioned the AKS cluster with the enabled managed identity, you need to set two parameters: <strong>useVMManagedIdentity<\/strong>&nbsp;and <strong>userAssignedIdentityID<\/strong><\/p>\n<p>The `<em>$identity<\/em>` variable stores the <strong>userAssignedIdentityID<\/strong>. If you do not specify **<strong>secretObjects<\/strong>**, you can only mount a volume. The system uses <strong>secretObjects<\/strong>&nbsp;to sync and create a Kubernetes secret. You can use this to set environmental variables in your deployment yml file. The secretObject name matches what you specified in the key vault. The deployment file uses the key to match and bring the secret in. Kubernetes creates, names, and uses this secret name.<\/p>\n<p><em>kv-sqldemo.yml** code:<\/em><\/p>\n<p><em>&nbsp; &nbsp; apiVersion: secrets-store.csi.x-k8s.io\/v1alpha1<br \/>\n&nbsp; &nbsp; kind: SecretProviderClass<br \/>\n&nbsp; &nbsp; metadata:<br \/>\n&nbsp; &nbsp; &nbsp; name: azure-sync<br \/>\n&nbsp; &nbsp; spec:<br \/>\n&nbsp; &nbsp; &nbsp; provider: azure<br \/>\n&nbsp; &nbsp; &nbsp; secretObjects: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # [OPTIONAL] SecretObject defines the desired state of synced K8s secret objects<br \/>\n&nbsp; &nbsp; &nbsp; &#8211; secretName: mssql &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# name of the Kubernetes Secret object<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; type: Opaque<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; data:&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &#8211; objectName: &#8220;mssql-secret&#8221; &nbsp; # name of the mounted content to sync, such as the object name or object alias&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; key: mssql &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # data field to populate. This must match in deployment yaml for key<br \/>\n&nbsp; &nbsp; &nbsp;parameters:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; useVMManagedIdentity: &#8220;true&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; userAssignedIdentityID: &#8220;7a1374c4-e517-4cdd-a655-85da17056c95&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; keyvaultName: &#8220;jrakskv&#8221; &nbsp; &nbsp; &nbsp; &nbsp;# the name of the KeyVault<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; objects: |<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;array:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#8211; |<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objectName: mssql-secret # key vault secret name<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objectType: secret &nbsp; &nbsp; &nbsp; # object types: secret, key or cert<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; tenantId: &#8220;&lt;insert tenantId here&gt;&#8221; # the tenant ID of the KeyVault<\/em><\/p>\n<p><em>Run `kubectl apply -f .\\kv-sqldemo.yml` to apply our configuration.<\/em><\/p>\n<p>Create a Microsoft\u00ae; SQL Server\u00ae (MS SQL) instance that pulls the mssql-secret generated during the key vault deployment as the System Administrator (SA) password.<\/p>\n<p>&nbsp;&#8212;<br \/>\n&nbsp; &nbsp; apiVersion: &#8220;v1&#8221;<br \/>\n&nbsp; &nbsp; kind: &#8220;ConfigMap&#8221;<br \/>\n&nbsp; &nbsp; metadata:<br \/>\n&nbsp; &nbsp; &nbsp; name: &#8220;mssql-config-map&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; namespace: default<br \/>\n&nbsp; &nbsp; &nbsp; labels:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; app: mssql<br \/>\n&nbsp; &nbsp; data:<br \/>\n&nbsp; &nbsp; &nbsp; MSSQL_PID: &#8220;Developer&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; ACCEPT_EULA: &#8220;Y&#8221;<br \/>\n&nbsp; &nbsp; &#8212;<br \/>\n&nbsp; <em>&nbsp; apiVersion: &#8220;v1&#8221;<br \/>\n&nbsp; &nbsp; kind: &#8220;Service&#8221;<br \/>\n&nbsp; &nbsp; metadata:<br \/>\n&nbsp; &nbsp; &nbsp; name: &#8220;mssql&#8221; #$(service name).$(namespace).svc.cluster.local<br \/>\n&nbsp; &nbsp; &nbsp; labels:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; app: mssql<br \/>\n&nbsp; &nbsp; spec:<br \/>\n&nbsp; &nbsp; &nbsp; clusterIP: &#8220;None&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; ports:<br \/>\n&nbsp; &nbsp; &nbsp; &#8211; port: 1433<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; name: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; selector:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; app: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; release: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &#8212;<br \/>\n&nbsp; &nbsp; apiVersion: v1<br \/>\n&nbsp; &nbsp; kind: Service<br \/>\n&nbsp; &nbsp; metadata:<br \/>\n&nbsp; &nbsp; &nbsp; name: mssql-lb<br \/>\n&nbsp; &nbsp; &nbsp; labels:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; app: mssql &nbsp;<br \/>\n&nbsp; &nbsp; spec:<br \/>\n&nbsp; &nbsp; &nbsp; selector:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; app: mssql<br \/>\n&nbsp; &nbsp; &nbsp; ports:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &#8211; protocol: TCP<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; port: 1433<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; targetPort: 1433<br \/>\n&nbsp; &nbsp; &nbsp; type: LoadBalancer<br \/>\n&nbsp; &nbsp; &#8212;<br \/>\n&nbsp; &nbsp; apiVersion: apps\/v1<br \/>\n&nbsp; &nbsp; kind: StatefulSet<br \/>\n&nbsp; &nbsp; metadata:<br \/>\n&nbsp; &nbsp; &nbsp;name: mssql&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp;labels:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;app: mssql<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;release: mssql<br \/>\n&nbsp; &nbsp; spec:<br \/>\n&nbsp; &nbsp; &nbsp; serviceName: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; selector:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; matchLabels:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;release: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; replicas: 1<br \/>\n&nbsp; &nbsp; &nbsp; updateStrategy:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; type: OnDelete<br \/>\n&nbsp; &nbsp; &nbsp; template:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;metadata:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labels:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; release: &#8220;mssql&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; spec:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nodeSelector:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;beta.kubernetes.io\/os&#8221;: linux &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; terminationGracePeriodSeconds: 180<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumes:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: secrets-store-inline<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; csi:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; driver: secrets-store.csi.k8s.io<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; readOnly: true<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeAttributes:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; secretProviderClass: &#8220;azure-sync&#8221;&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;containers:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: mssql<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image: mcr.microsoft.com\/mssql\/server:2017-latest &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resources:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {}<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ports:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; containerPort: 1433<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: mssql<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; envFrom:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; configMapRef:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: mssql-config-map<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; env:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: MSSQL_PID<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valueFrom:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; configMapKeyRef:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: mssql-config-map<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; key: MSSQL_PID<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: ACCEPT_EULA<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valueFrom:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; configMapKeyRef:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: mssql-config-map<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; key: ACCEPT_EULA<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: SA_PASSWORD #env variable to create<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valueFrom:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; secretKeyRef:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: mssql #k8s secret name. (kubectl get secret). this is auto synced during creation and deletion of the POD<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; key: mssql #this must match the kv configuration in the yaml under secretObjects<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeMounts:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: mssql-pvc<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mountPath: \/var\/opt\/mssql<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: secrets-store-inline&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mountPath: &#8220;\/mnt\/secrets-store&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;readOnly: true<br \/>\n&nbsp; &nbsp; &nbsp; volumeClaimTemplates: #default is standard storage. managed-premium is ssd<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &#8211; metadata:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: mssql-pvc &nbsp; &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spec:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;storageClassName: default<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; accessModes:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; ReadWriteOnce<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resources:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; requests:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;storage: 4Gi<\/em><\/p>\n<p>\n<strong>Note<\/strong>: You must create a volume with a <strong>secretProviderClass<\/strong>&nbsp;that matches the name you specified in the <strong>secretproviderclasses<\/strong>&nbsp;resource that you created previously.&nbsp;<\/p>\n<p>Mount a volume with access to your secrets. This exposes secrets so that a script can output the value, as shown here:<\/p>\n<p>&nbsp; &nbsp;<em> &nbsp; &nbsp; &#8211; name: secrets-store-inline<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; csi:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; driver: secrets-store.csi.k8s.io<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; readOnly: true<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeAttributes:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; secretProviderClass: &#8220;azure-sync&#8221;&nbsp;<\/em><\/p>\n<p><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8211; name: secrets-store-inline&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mountPath: &#8220;\/mnt\/secrets-store&#8221;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; readOnly: true<\/em><\/p>\n<p>Finally, apply our mssql yml file by running this command:&nbsp;<\/p>\n<p><em>`k apply -f .\\mssqlStateful.yml`<\/em><\/p>\n<p>After the pod starts and the secret syncs, verify that the password is set as an environmental variable:<\/p>\n<p><em>&nbsp; &nbsp; kubectl get pods<\/em><\/p>\n<p>&nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;READY &nbsp; STATUS &nbsp; &nbsp;RESTARTS &nbsp; AGE<br \/>\n<em>&nbsp; &nbsp; csi-secrets-store-provider-azure-1589209035-secrets-store-pwnsz &nbsp; 3\/3 &nbsp; &nbsp; Running &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;29m<br \/>\n&nbsp; &nbsp; csi-secrets-store-provider-azure-1589209035-xcqz9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1\/1 &nbsp; &nbsp; Running &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;29m<br \/>\n&nbsp; &nbsp; mssql-0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1\/1 &nbsp; &nbsp; Running &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6m30s<\/em><\/p>\n<p><em>&nbsp; &nbsp; kubectl get secret<\/em><\/p>\n<p>&nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DATA &nbsp; AGE<br \/>\n&nbsp; &nbsp;<em> default-token-7hvrq &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kubernetes.io\/service-account-token &nbsp; 3 &nbsp; &nbsp; &nbsp;37m<br \/>\n&nbsp; &nbsp; mssql &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Opaque &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;10m<br \/>\n&nbsp; &nbsp; secrets-store-csi-driver-token-bdsjk &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;kubernetes.io\/service-account-token &nbsp; 3 &nbsp; &nbsp; &nbsp;33m<br \/>\n&nbsp; &nbsp; sh.helm.release.v1.csi-secrets-store-provider-azure-1589209035.v1 &nbsp; helm.sh\/release.v1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp;33m<\/em><\/p>\n<p><em>&nbsp; &nbsp; kubectl exec -t mssql-0 printenv | findstr SA_PASSWORD &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; SA_PASSWORD=fjL-dh.hq0!4<\/em><\/p>\n<p>You can also grab the public IP address of the load balancer and connect to it by using SQL Management Studio with the SA account by using the password set from Azure Key Vault:<\/p>\n<p>&nbsp; &nbsp; kubectl get service -l app=mssql<\/p>\n<p>&nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLUSTER-IP &nbsp; EXTERNAL-IP &nbsp; PORT(S) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AGE<br \/>\n<em>&nbsp; &nbsp; mssql &nbsp; &nbsp; &nbsp;ClusterIP &nbsp; &nbsp; &nbsp;None &nbsp; &nbsp; &nbsp; &nbsp; &lt;none&gt; &nbsp; &nbsp; &nbsp; &nbsp;1433\/TCP &nbsp; &nbsp; &nbsp; &nbsp; 20m<br \/>\n&nbsp; &nbsp; mssql-lb &nbsp; LoadBalancer &nbsp; 10.0.7.128 &nbsp; 40.119.2.73 &nbsp; 1433:31264\/TCP &nbsp; 20m<\/em><br \/>\n&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26451-body-ssms.png\" alt=\"SSMS Pic 1\" \/><\/p>\n<p>\nUsing Azure Key Vault with AKS has never been easier. I hope this demo shows some possibilities of things that you can accomplish easily with the Azure Key Vault provider.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use the Azure Secret Store CSI driver in AKS<\/p>\n","protected":false},"author":2,"featured_media":7613,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"content-type":"","nid":"26451","content_type":"blog","created_by":"10130","authored_on":"2024-01-05T10:06:57+00:00","field_article_industries":"","tag_category":"Technical","field_blog_author_text":"by Rackspace Technical Staff","seo_description":"Utilize Azure Secret Store CSI Driver in AKS for enhanced security and configuration. Simplify deployment and integration with keys and secrets.\r\n","field_featured_image":"","insights_image":"\/wp-content\/uploads\/2026\/blog_technical_images\/26451-insights_image-microsoft-technical-blog-1-insights.jpg","field_partners":"","rxt_platforms":"Microsoft Azure","product":"","publisheddate":"2020-05-13T09:06:57","rxt_solutions":"Cloud Management & Operations","opengraph_tag":"","x_tag":"","teaser_flag":"Technical Blog","seo_titile":"Azure Secret Store CSI driver in AKS | Rackspace Technology","field_topics":"","field_slug":"using-the-azure-secrets-store-csi-in-aks-driver","footnotes":""},"categories":[178],"tags":[204],"class_list":["post-7611","blogs","type-blogs","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-technical"],"_links":{"self":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs"}],"about":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/types\/blogs"}],"author":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/comments?post=7611"}],"version-history":[{"count":3,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7611\/revisions"}],"predecessor-version":[{"id":9565,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7611\/revisions\/9565"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media\/7613"}],"wp:attachment":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media?parent=7611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/categories?post=7611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/tags?post=7611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}