Mount Azure Blob containers with NFS in AKS Cluster

Objective

Prerequisites

  • AKS Cluster in supported version with CSI Blob drivers enabled. If your cluster doesn’t have these drivers enabled, you can update your deployment with the following command:
az aks update --enable-blob-driver -n myAKSCluster -g myResourceGroupaz aks update --enable-blob-driver -n myAKSCluster -g myResourceGroup

Storage Account implementation

AKS Manifests

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: azureblob-nfs-premium
provisioner: blob.csi.azure.com
parameters:
protocol: nfs
tags: environment=Development
volumeBindingMode: Immediate
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-blob
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain # If set as "Delete" container would be removed after pvc deletion
storageClassName: azureblob-nfs-premium
csi:
driver: blob.csi.azure.com
readOnly: false
# make sure this volumeid is unique in the cluster
# `#` is not allowed in self defined volumeHandle
volumeHandle: MC_aks_aks_westeurope#azstorageblobtest#nginx-blob
volumeAttributes:
resourceGroup: MC_aks_aks_westeurope
storageAccount: azstorageblobtest
containerName: nginx-blob
protocol: nfs
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-blob
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
volumeName: pv-blob
storageClassName: azureblob-nfs-premium
kind: Pod
apiVersion: v1
metadata:
name: nginx-blob
spec:
nodeSelector:
"kubernetes.io/os": linux
containers:
- image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine
name: nginx-blob
volumeMounts:
- name: blob01
mountPath: "/mnt/blob"
volumes:
- name: blob01
persistentVolumeClaim:
claimName: pvc-blob

Testing

mkdir /mnt/nfs
mount -o sec=sys,vers=3,nolock,proto=tcp azstorageblobtest.blob.core.windows.net:/azstorageblobtest/aks /mnt/nfs

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store