Microsoft

Azure Kubernetes Service (AKS) Storage

This document explores how to integrate Azure storage solutions with Azure Kubernetes Service (AKS) clusters to provide persistent storage for your containerized applications.

Understanding Kubernetes Storage Concepts

Kubernetes provides a robust storage abstraction layer that allows applications to request and consume storage without direct knowledge of the underlying infrastructure. Key concepts include:

  • Volumes: A directory with a persistent identifier that survives pod restarts. Kubernetes supports various volume types, including cloud provider volumes.
  • PersistentVolumes (PV): A piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. PVs are cluster resources.
  • PersistentVolumeClaims (PVC): A request for storage by a user. PVCs consume PV resources. Pods request storage through PVCs.
  • StorageClasses: Define different classes of storage with varying quality-of-service levels, backup policies, and other parameters. They enable dynamic provisioning of PVs.

Azure Storage Options for AKS

AKS integrates seamlessly with several Azure storage services:

Azure Disks

Azure Disks provide highly performant, persistent block storage for AKS nodes. They are suitable for demanding workloads that require low latency and high IOPS.

  • Types: Ultra Disk, Premium SSD, Standard SSD, Standard HDD.
  • Provisioning: Dynamically provisioned using a StorageClass.
  • Access Modes: ReadWriteOnce (RWO).

Here's an example of a PVC for Azure Disks:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azure-disk-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: managed-premium 
  resources:
    requests:
      storage: 10Gi 
  

The managed-premium StorageClass typically maps to Azure Premium SSDs.

Azure Files

Azure Files offers fully managed cloud file shares accessible via the industry-standard Server Message Block (SMB) protocol. It's ideal for shared storage scenarios where multiple pods need to access the same data.

  • Types: Premium, Transaction Optimized, Hot, Cool.
  • Provisioning: Can be provisioned dynamically using a StorageClass or statically.
  • Access Modes: ReadWriteMany (RWX), ReadOnlyMany (ROX).

Example PVC for Azure Files:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azure-files-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile-premium
  resources:
    requests:
      storage: 50Gi
  

The azurefile-premium StorageClass typically maps to Azure Premium file shares.

Azure Blob Storage (via CSI Driver)

For object storage needs, you can leverage Azure Blob Storage through the Azure Blob CSI driver. This allows you to mount blob containers as volumes within your pods.

  • Use Cases: Storing large amounts of unstructured data, backups, static website content.
  • Access Modes: Primarily ReadWriteOnce (RWO) or ReadOnlyMany (ROX) depending on the configuration and driver.

Refer to the official Azure Blob CSI driver documentation for specific PVC configurations.

Dynamic Provisioning with StorageClasses

AKS includes several pre-configured StorageClasses that you can use:

  • managed-premium: For Azure Managed Disks (Premium SSD).
  • managed-standard: For Azure Managed Disks (Standard HDD).
  • azurefile: For Azure Files (Standard).
  • azurefile-premium: For Azure Files (Premium).

You can create custom StorageClasses to define specific configurations, such as replication, IOPS limits, or different disk types.

Static Provisioning

While dynamic provisioning is recommended, you can also manually create PersistentVolumes (PVs) and then bind them to PersistentVolumeClaims (PVCs).

Note: For most scenarios, dynamic provisioning using StorageClasses is the preferred and more flexible approach.

Best Practices for AKS Storage

  • Choose the right Azure storage solution based on your application's performance, cost, and access pattern requirements.
  • Use StorageClasses for dynamic provisioning to automate storage management.
  • Consider the lifecycle of your data and implement appropriate backup and recovery strategies.
  • Monitor storage utilization and performance to ensure optimal application operation.
  • Understand the access modes (RWO, RWX, ROX) and ensure they match your application's needs.

For more detailed information and advanced configurations, please refer to the official Azure Disks documentation and Azure Files documentation.