k8s Storage Class AzureDisk

Kubernetes Dynamic Cloud Storage Provisioning(Azure)

Assuming Azure user subscription in place and had enough resource access to provision the Storage.

Simple 4 steps to create Resource group, AKS cluster, and storage account from Azure CLI or PowerShell(your choice of where supported utilities are installed):

$  az group create --resource-group pvtest --location eastus

$ az aks create --resource-group pvtest  --name pvaks --node-count 2 \
    --generate-ssh-keys  --attach-acr k8acr01demo

$ az aks get-credentials --resource-group pvtest  --name pvaks

$ az storage account create --name dynamicpv1 --resource-group \
    mc_pvtest_pvaks_eastus --access-tier Hot --allow-blob-public-access false \
    --kind storagev2 --sku Standard_LRS --tags dynamicpv:pvaks

Before Choose the provisioner, go through your needs and types of storage provided by Azure.

Traditional volumes to store and retrieve data are created as Kubernetes resources backed by Azure Storage. You can manually create these data volumes to be assigned to pods directly, or have Kubernetes automatically create them. These data volumes can use Azure Disks or Azure Files:

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. For most production and development workloads, use Premium storage. Azure Disks are mounted as ReadWriteOnce, so are only available to a single pod. 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 share backed by an Azure Storage account to pods. Files let you share data across multiple nodes and pods. Files can use Azure Standard storage backed by regular HDDs, or Azure Premium storage, backed by high-performance SSDs.

Here, I am going to demonstrate Azure Disk as my provisioner. 


Create the Dynamic Storage class and: 

cat  << EOF > dynamicSC.yaml
apiVersion: storage.k8s.io/v1beta1
kind: StorageClass
  name: dynamicpv
    storageclass.beta.kubernetes.io/is-default-class: "false"
    kubernetes.io/cluster-service: "true"
provisioner: kubernetes.io/azure-disk
allowVolumeExpansion: true
  skuName: Standard_LRS
  location: eastus
  storageAccount: dynamicpv

kubectl create -f dynamicSC.yaml

Check the created SC:

Precheck for existing PVs:

$ kubectl get pv

Create the new PVC:

cat  << EOF > pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
  name: dynamicpv
  - ReadWriteOnce
  storageClassName: dynamicpv
      storage: 5Gi

kubectl create -f pvc.yaml

Now check the created PVC along auto-provisioned PV should create automatically.

cat  << EOF > Deploy.yaml
apiVersion: apps/v1
kind: Deployment
  name: nginx-deployment
    app: nginx
  replicas: 1
      app: nginx
        app: nginx
      - name: nginx
        image: nginx:latest
        - containerPort: 80
        - name: pvtest
          mountPath: /mnt/pvtest
      - name: pvtest
           claimName: dynamicpvc

$ kubectl create -f Deploy.yaml

It is the time to use the claimed PVC in the pod template.

Now exec the Pod to check the status:

So far our requirement satisfied and even after the pod dies it recreates and mounts the cloud disk back to Pod. ... Hopefully, this is what you are looking to achieve for a single pod


Now let us try to scale the pods as there was a user requirement:

$ kubectl scale deploy/nginx-deployment --replicas=3

deployment.apps/nginx-deployment scaled

Something went wrong and Pod ended in a pending state. let us troubleshoot.

$ kubectl describe pod/nginx-deployment-6cd8847749-bd5zz

How to overcome:

we can use Azure file storage for stateless applications. One volume mount can be shared with many pods using the access mode "READWRITEMANY" AzureFile_provision option.

For Statefulsets, altogether a different concept. Since applications demand Data persistence with Data replication on a master-slave basis. 

"Here is a nice presentation to beginners by Nana:




  1. You can also access exclusive poker bonuses and customization features. The entire platform is out there on tablets and could be accessed directly from your cell browser. This article is informative these who|for many who|for individuals who} need to familiarize themselves with temporary details about present games to make the proper alternative for 1xbet themselves. If a casino cooperates with famous gaming software program providers, players extra likely to|usually have a tendency to} register on such a website.


Post a Comment

Popular Posts