k8s Storage Class AzureDisk
Kubernetes Dynamic Cloud Storage Provisioning(Azure)
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
--generate-ssh-keys --attach-acr k8acr01demo
$ az aks get-credentials --resource-group pvtest --name pvaks
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.
Steps:
Create the Dynamic Storage class and:
apiVersion: storage.k8s.io/v1beta1
kind: StorageClass
name: dynamicpv
annotations:
storageclass.beta.kubernetes.io/is-default-class: "false"
labels:
kubernetes.io/cluster-service: "true"
provisioner: kubernetes.io/azure-disk
allowVolumeExpansion: true
parameters:
skuName: Standard_LRS
location: eastus
storageAccount: dynamicpv
EOF
$ kubectl create -f dynamicSC.yaml
Check the created SC:
Precheck for existing PVs:
Create the new PVC:
kind: PersistentVolumeClaim
metadata:
name: dynamicpv
spec:
accessModes:
- ReadWriteOnce
storageClassName: dynamicpv
resources:
requests:
storage: 5Gi
Now check the created PVC along auto-provisioned PV should create automatically.
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: pvtest
mountPath: /mnt/pvtest
volumes:
- name: pvtest
persistentVolumeClaim:
claimName: dynamicpvc
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
Addon:
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:
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.
ReplyDelete