Using Azure Files Storage¶
Platform operators can provide persistent storage for workloads running on MKE and Microsoft Azure by using Azure Files. You can either pre-provision Azure Files Shares to be consumed by Kubernetes Pods or can you use the `Azure Kubernetes integration to dynamically provision Azure Files Shares on demand.
This guide assumes you have already provisioned a MKE environment on Microsoft Azure. The cluster must be provisioned after meeting all prerequisites listed in MKE Deployment Guide: Install MKE on Azure.
Additionally, this guide uses the Kubernetes Command Line tool kubectl to provision Kubernetes objects within a MKE cluster. Therefore, you must download this tool along with a MKE client bundle.
Manually Provisioning Azure Files¶
You can use existing Azure Files Shares or manually provision new ones to provide persistent storage for Kubernetes Pods. Azure Files Shares can be manually provisioned in the Azure Portal using ARM Templates or using the Azure CLI. The following example uses the Azure CLI to manually provision Azure Files Shares.
Creating an Azure Storage Account¶
When manually creating an Azure Files Share, first create an Azure Storage Account for the file shares. If you have already provisioned a Storage Account, you can skip to “Creating an Azure Files Share.”
The Azure Kubernetes Driver does not support Azure Storage Accounts created using Azure Premium Storage.
$ REGION=ukwest $ SA=mystorageaccount $ RG=myresourcegroup $ az storage account create \ --name $SA \ --resource-group $RG \ --location $REGION \ --sku Standard_LRS
Configuring a Kubernetes Secret¶
After a File Share has been created, you must load the Azure Storage Account Access key as a Kubernetes Secret into MKE. This provides access to the file share when Kubernetes attempts to mount the share into a pod. This key can be found in the Azure Portal or retrieved as shown in the following example by the Azure CLI.
$ SA=mystorageaccount $ RG=myresourcegroup $ FS=myfileshare # The Azure Storage Account Access Key can also be found in the Azure Portal $ STORAGE_KEY=$(az storage account keys list --resource-group $RG --account-name $SA --query ".value" -o tsv) $ kubectl create secret generic azure-secret \ --from-literal=azurestorageaccountname=$SA \ --from-literal=azurestorageaccountkey=$STORAGE_KEY