Wed. Oct 5th, 2022

Hello Android

All android in one place

Azure File Share – Dynamic Storage Provisioner in AKS

4 min read

Hello, readers! This article talks about Azure File Share as a Dynamic Storage Provisioner in AKS with a practical demonstration.

So, let us begin! 🙂

What is Azure File Share?

We have now been moving our applications to the containers. From the storage perspective, we still need a concrete solution to have our data stored safely.

Read: Build and Push Image to Azure Container Registry : Practical Implementation

Talking specifically about the open-source cloud giants, they offer different ways to have our data stored securely.

In the current scene, we have different types of database and storage options available as a managed service such as –

  • Azure File share
  • Azure Blob Storage
  • Google Cloud Instances
  • BigQuery
  • Managed SQL Instances
  • Amazon S3
  • Cloud SQL Proxy server setup, etc.

The above database/storage options can be integrated with the container vertical.

This article specifically focuses on Azure File share as the storage option for applications deployed as a container in the Kubernetes environment.

Azure File share is a storage option to have the data/files stored within it and managed globally by an Azure Storage Account. It is a fully managed storage solution offered by Microsoft Azure. The file share is based on the Server Message Block protocol.

With Azure File share, we can mount our data easily across various underlying infrastructure resources such as Virtual Machines, Azure Kubernetes Container Instances, Kubernetes Services, etc.

At first, we need a Storage account in place to initiate the boundary of the File Share. Once the Storage account is in place, we can navigate to the same in the Azure Web Interface and all the data stored will be visible under the File Shares section.

Azure File Share

In the upcoming section, we will be making use of Azure File share for Dynamic Persistent data storage in Kubernetes.

Set up Azure File share for Dynamic Persistent storage

In order to set up Azure File share as a Kubernetes Dynamic Persistent Storage solution, we need to follow the below steps-

  • Create a Storage Class in the Kubernetes environment
  • Provision a Persistent Volume Claim
  • Use the PVC in the Kubernetes Deployment
  • Test the data in the Azure File Share

1. Set up a Storage Class in Azure Kubernetes Service

In order to have persistent data storage, we need to create a storage class to define the hierarchy and type of data storage.

Have a look at the below code-

kind: StorageClass
  name: filestore-demo
  namespace: demons
  resourceGroup: rg-demo
  skuName: Standard_LRS
  storageAccount: demostgacc
reclaimPolicy: Delete
volumeBindingMode: Immediate

In this example, we have created a storage class of provisioner azure-file which is a default one. We need to mention the storage account name as well as other details such as resource group, volume binding mode, etc.

2. Create a Persistent Volume Claim

Having created a storage class, we then use it to provide a persistent volume claim as shown below-

apiVersion: v1
kind: PersistentVolumeClaim
  name: pvc-demo
  namespace: demons
  - ReadWriteMany
      storage: 1Gi
  storageClassName: filestore-demo
  volumeMode: Filesystem

Here, we make use of the storage class name to build a PVC that utilizes the capabilities and offerings of a storage class type to provision a volume at the backend of a particular specified size and with an appropriate configuration (such as ReadWriteMany, ReadWriteOnce, etc).

3. Use the PVC in the Kubernetes Deployment

Once we are ready with the PVC, it dynamically creates a persistent volume at the backend of the specified size which is expandable.

We then refer to the PVC details in the deployment file for the container to use once provisioned.

Have a look at the below YAML!

apiVersion: apps/v1
kind: Deployment
  name: demo
  namespace: demons
      app: demo
  replicas: 1
    type: Recreate
        app: demo
        - name: demo
          image: hello-world
              cpu: 100m
              memory: 1Gi
              cpu: 60m
              memory: 900Mi
          - name: demo 
            mountPath: "/demo/cronjob"    
      serviceAccountName: demo-sa
      - name: demo  
          claimName: pvc-demo 
      - name: secret-key 

In this YAML file, we have referred to the volume to be of type PVC and we have given a designated mount path on which it will be available from within the container.

Once we run the container, we can check for the data that gets stored in the Azure File share by browsing the storage account associated with it in Azure-


Image 6
Azure File share


By this, we have approached the end of this topic. Feel free to comment below, in case you come across any questions.

For more such posts related to Kubernetes and Azure, Stay tuned with us.

Till then, Happy Learning!! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Hello android © All rights reserved. | Newsphere by AF themes.