Creating a Storage Class in Microsoft Azure
Introduction
Azure volumes can be:
Azure Disks
Azure Files
Azure NetApp Files
Azure Blobs.
To provide a PersistentVolume, you can use only:
As noted in the Volumes section, the choice of Disks or Files is often determined by the need for concurrent access to the data or the performance tier.
Prerequisites
Make sure you have an existing AKS Cluster.
Make sure you're connected to the cluster. Quickstart: Deploy an Azure Kubernetes Service cluster using the Azure CLI
Steps to create Disk and Network Volumes
The main focus of the next steps is preparing your cluster to support Disk Volumes.
1. Create a file named csi_rwo.yaml.
2. Copy and paste the content below into the csi_rwo.yaml file:
The complete list of valid SKU types is available on the Microsoft documentation website.
3. Save the file and exit from edit mode
4. Apply the file to Kubernetes using the following command:
Testing the Storage Class
1. Create a file named claim_rwo.yaml and paste the content below inside it.
2. Apply the claim:
3. Now it's time to create a pod that uses the claim. Create a new file named pod.yaml and paste the content below inside it:
4. Apply the file
5. Make sure everything worked out:
6. Now let's check if the pod is running:
7. Cleanup the resources:
The volume type disk will be automatically provisioned by Azure using the defined storage class.
The NFS component that has the Volume mounted will be exported using a Kubernetes deployment.
Creating a NFS server
Start by creating a deployment file nfs-deployment.yaml:
Apply the deployment file:
This will create the container which will export a host volume
Creating a Kubernetes service for nfs-deployment.yaml
Create a file named service.yaml containing the text below:
Apply the file
Wait for the service and pod to be created. Check status using commands:
Use Helm charts to create the Storage Class
Retrieve the Service Endpoint IP using the command below:
In this case, 10.244.0.15 is the NFS Server IP which will be used in the Helm Chart command.
2049 is the port used for NFS mounts.
Add the following Helm Chart repository:
Use the Helm Chart to create the Storage Class:
Replace NFS_SERVICE_ENDPOINT_IP with the IP of your NFS service Endpoint. In our case, the IP is
10.244.0.15(visible in the Output of a previous step).
Verifying the presence of the bns-network-sc storage class
Wait until the Storage Class is created, check status using command:
Testing the Storage Class
1. Create the test.yaml file with the contents below.
2. Apply test.yaml:
3. Let's make sure that test-pvc-network has the status Bound by performing the next command:
4. Check that the pod reached the Running status by performing the following command:
5. Verify that the test-app-network pod is writing data to the volume:
6. If your results are similar with the Output displayed above, then you've completed the process successfully and you can delete the test resources.
Delete the PVC and the Pod. This will also cause the PV to be deleted:
Last updated
Was this helpful?
