K8s Storage: Defining Custom StorageClass in Azure.
I suppose the first (and highly valid) question is: Why should I worry about creating a custom StorageClass? Shouldn't the menu offered by CSPs and other storage service providers be enough for my most esoteric needs?
The simple answer is you should avoid creating something if you can find a pre-made, tested and managed alternative BUT since we are attempting to become theoretically proficient in the nuances of K8s storage, learning about custom StorageClasses will only add to our knowledge.
StorageClass gives application developers a way to get a volume without knowing exactly how it is implemented. It gives applications a way to request a PVC without knowing exactly which type of PersistentVolume is being used under the hood.
Demo: Custom StorageClass for Azure EKS.
- Azure EKS instance
- kubectl (installed locally)
Step 1: List the StorageClasses available in Azure EKS.
Step 2: Make a manifest for a StorageClass NOT available in Azure EKS.
(We did say we want to make a custom Storageclass)
The manifest is asking Kube-API server to:
- Make a StorageClass named sc-custom-standard-ssd
- Set the cachingmode for this StorageClass to be ReadOnly
- Set the storageaccounttype to StandardSSD_LRS
Using $ kubectl create -f custom-storageclass-azure.yaml, the StorageClass is created and we can confirm that by listing all StorageClasses again.
Step 3: Deploy the Pod and its associated PVC (which uses the custom StorageClass from Step 2).
I write to remember and if in the process, I can help someone learn about Containers, Orchestration (Docker Compose, Kubernetes), GitOps, DevSecOps, VR/AR, Architecture, and Data Management, that is just icing on the cake.