Container Storage Interface (CSI) drivers on Azure Kubernetes Service (AKS)
The Container Storage Interface (CSI) is a standard for exposing arbitrary block and file storage systems to containerized workloads on Kubernetes. By adopting and using CSI, Azure Kubernetes Service (AKS) can write, deploy, and iterate plug-ins to expose new or improve existing storage systems in Kubernetes without having to touch the core Kubernetes code and wait for its release cycles.
The CSI storage driver support on AKS allows you to natively use:
- Azure Disks can be used to create a Kubernetes DataDisk resource. Disks can use Azure Premium Storage, backed by high-performance SSDs, or Azure Standard Storage, backed by regular HDDs or Standard SSDs. For most production and development workloads, use Premium Storage. Azure Disks are mounted as ReadWriteOnce and are only available to one node in AKS. For storage volumes that can be accessed by multiple pods simultaneously, use Azure Files.
- Azure Files can be used to mount an SMB 3.0/3.1 share backed by an Azure storage account to pods. With Azure Files, you can share data across multiple nodes and pods. Azure Files can use Azure Standard storage backed by regular HDDs or Azure Premium storage backed by high-performance SSDs.
- Azure Blob storage can be used to mount Blob storage (or object storage) as a file system into a container or pod. Using Blob storage enables your cluster to support applications that work with large unstructured datasets like log file data, images or documents, HPC, and others. Additionally, if you ingest data into Azure Data Lake storage, you can directly mount and use it in AKS without configuring another interim filesystem.
Important
Starting with Kubernetes version 1.21, AKS only uses CSI drivers by default and CSI migration is enabled. Existing in-tree persistent volumes will continue to function. However, internally Kubernetes hands control of all storage management operations (previously targeting in-tree drivers) to CSI drivers.
In-tree drivers refers to the storage drivers that are part of the core Kubernetes code opposed to the CSI drivers, which are plug-ins.
Note
Azure Disks CSI driver v2 (preview) improves scalability and reduces pod failover latency. It uses shared disks to provision attachment replicas on multiple cluster nodes and integrates with the pod scheduler to ensure a node with an attachment replica is chosen on pod failover. Azure Disks CSI driver v2 (preview) also provides the ability to fine tune performance. If you're interested in participating in the preview, submit a request: https://aka.ms/DiskCSIv2Preview. This preview version is provided without a service level agreement, and you can occasionally expect breaking changes while in preview. The preview version isn't recommended for production workloads. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
Prerequisites
You need the Azure CLI version 2.40 installed and configured. Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI.
Disable CSI storage drivers on a new cluster
--disable-disk-driver allows you to disable the Azure Disks CSI driver. --disable-file-driver allows you to disable the Azure Files CSI driver. --disable-snapshot-controller allows you to disable the snapshot controller.
To disable CSI storage drivers on a new cluster, use --disable-disk-driver, --disable-file-driver, and --disable-snapshot-controller.
az aks create -n myAKSCluster -g myResourceGroup --disable-disk-driver --disable-file-driver --disable-snapshot-controller
Disable CSI storage drivers on an existing cluster
To disable CSI storage drivers on an existing cluster, use --disable-disk-driver, --disable-file-driver, and --disable-snapshot-controller.
az aks update -n myAKSCluster -g myResourceGroup --disable-disk-driver --disable-file-driver --disable-snapshot-controller
Enable CSI storage drivers on an existing cluster
--enable-disk-driver allows you enable the Azure Disks CSI driver. --enable-file-driver allows you to enable the Azure Files CSI driver. --enable-snapshot-controller allows you to enable the snapshot controller.
To enable CSI storage drivers on an existing cluster with CSI storage drivers disabled, use --enable-disk-driver, --enable-file-driver, and --enable-snapshot-controller.
az aks update -n myAKSCluster -g myResourceGroup --enable-disk-driver --enable-file-driver --enable-snapshot-controller
Migrate custom in-tree storage classes to CSI
If you've created in-tree driver storage classes, those storage classes continue to work since CSI migration is turned on after upgrading your cluster to 1.21.x. If you want to use CSI features you'll need to perform the migration.
Migrating these storage classes involves deleting the existing ones, and re-creating them with the provisioner set to disk.csi.azure.com if using Azure Disks, and files.csi.azure.com if using Azure Files.
Migrate storage class provisioner
The following example YAML manifest shows the difference between the in-tree storage class definition configured to use Azure Disks, and the equivalent using a CSI storage class definition. The CSI storage system supports the same features as the in-tree drivers, so the only change needed would be the value for provisioner.
Original in-tree storage class definition
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: custom-managed-premium
provisioner: kubernetes.io/azure-disk
reclaimPolicy: Delete
parameters:
storageAccountType: Premium_LRS
CSI storage class definition
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: custom-managed-premium
provisioner: disk.csi.azure.com
reclaimPolicy: Delete
parameters:
storageAccountType: Premium_LRS
The CSI storage system supports the same features as the In-tree drivers, so the only change needed would be the provisioner.
Migrate in-tree persistent volumes
Important
If your in-tree persistent volume reclaimPolicy is set to Delete, you need to change its policy to Retain to persist your data. This can be achieved using a patch operation on the PV. For example:
kubectl patch pv pv-azuredisk --type merge --patch '{"spec": {"persistentVolumeReclaimPolicy": "Retain"}}'
Migrate in-tree Azure Disks persistent volumes
If you have in-tree Azure Disks persistent volumes, get diskURI from in-tree persistent volumes and then follow this guide to set up CSI driver persistent volumes.
Migrate in-tree Azure File persistent volumes
If you have in-tree Azure File persistent volumes, get secretName, shareName from in-tree persistent volumes and then follow this guide to set up CSI driver persistent volumes
Next steps
- To use the CSI driver for Azure Disks, see Use Azure Disks with CSI drivers.
- To use the CSI driver for Azure Files, see Use Azure Files with CSI drivers.
- To use the CSI driver for Azure Blob storage, see Use Azure Blob storage with CSI drivers
- For more about storage best practices, see Best practices for storage and backups in Azure Kubernetes Service.
- For more information on CSI migration, see Kubernetes In-Tree to CSI Volume Migration.
Feedback
Submit and view feedback for