Container Storage Interface (CSI) Drivers on Azure Kubernetes Service (AKS)
The Container Storage Interface (CSI) is a standard API that exposes arbitrary block and file storage systems to containerized workloads on orchestrators like Kubernetes. CSI drivers enable storage providers to develop and deploy storage solutions without needing to modify the core Kubernetes code.
Azure provides integrated CSI drivers that allow you to attach and manage Azure managed disks and Azure Files within your AKS clusters. This document explores the concepts and implementation of CSI drivers in AKS.
Why Use CSI Drivers?
- Extensibility: Allows third-party storage vendors to integrate their solutions seamlessly.
- Flexibility: Supports a wide range of storage types beyond native Kubernetes storage options.
- Performance: Can offer optimized performance characteristics for specific storage needs.
- Standardization: Provides a consistent way to manage storage across different cloud providers and on-premises solutions.
Azure CSI Drivers
AKS offers two primary CSI drivers for Azure storage:
1. Azure Disk CSI Driver
This driver allows you to use Azure Managed Disks as persistent storage for your Kubernetes workloads. You can provision standard and premium SSD disks, as well as Ultra Disks.
Key Features:
- Dynamic provisioning of Azure Managed Disks.
- Support for read-write-once (RWO) persistent volumes.
- Volume snapshots and cloning.
- Volume expansion.
Example PersistentVolumeClaim (PVC):
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-azure-disk-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: managed-premium
resources:
requests:
storage: 10Gi
Note: The storageClassName refers to the pre-defined or custom storage classes available in your AKS cluster, which map to different Azure disk types (e.g., managed-premium, managed-standard, azure-disk-csi).
2. Azure File CSI Driver
This driver enables the use of Azure Files shares, which provide fully managed file shares accessible via the Server Message Block (SMB) protocol. This is ideal for scenarios requiring shared file access.
Key Features:
- Dynamic provisioning of Azure Files shares.
- Support for read-write-many (RWX) persistent volumes.
- Mounting of existing Azure Files shares.
- Secret management for credentials.
Example PersistentVolumeClaim (PVC):
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-azure-file-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: azurefile-csi
resources:
requests:
storage: 5Gi
Tip: For ReadWriteMany access modes with Azure Files, ensure your Kubernetes version supports it and that you use the appropriate storageClassName.
Enabling CSI Drivers in AKS
By default, AKS enables the Azure Disk and Azure File CSI drivers for new clusters. For older clusters or specific configurations, you might need to enable them manually.
When creating an AKS cluster using the Azure CLI, CSI drivers are typically enabled by default. If you need to explicitly manage them or disable legacy in-tree volume plugins, you can use parameters like --enable-managed-identity (for certain CSI driver features) and ensure that the CSI drivers are not overridden.
For existing clusters, you can verify the installation of CSI drivers by checking for the corresponding pods in the kube-system namespace:
kubectl get pods -n kube-system -l app.kubernetes.io/instance=azure-disk-csi-driver
kubectl get pods -n kube-system -l app.kubernetes.io/instance=azure-file-csi-driver
Storage Classes
CSI drivers are configured through Kubernetes StorageClass objects. AKS automatically creates default Storage Classes for the Azure Disk and Azure File CSI drivers.
Default Azure Storage Classes:
managed-premium: Uses Azure Premium SSD Managed Disks.
managed-standard: Uses Azure Standard HDD/SSD Managed Disks.
azurefile-csi: Uses Azure Files.
azurefile-premium-csi: Uses Azure Premium Files.
You can list available Storage Classes with:
kubectl get sc
Considerations for Production
Important:
- Choose the appropriate Storage Class based on your performance and cost requirements.
- Understand the access modes (RWO, ROX, RWX) supported by each CSI driver and your application's needs.
- Plan for volume expansion and snapshotting strategies for data resilience.
- Monitor the performance and availability of your Azure storage.
Further Reading