Exercise Overview: This exercise focuses on utilizing dynamic volumes in Azure Kubernetes Service (AKS). You'll go through the process of creating a resource group, provisioning a service principal, setting up an AKS cluster, and implementing dynamic volumes using Azure Disk and Azure File.
- Azure Subscription
- Azure Kubernetes Service (AKS) Cluster (Perform steps 1 to 4 if not already running)
- Azure CLI
- SSH Key Pair
Solution
Creates an Azure Resource Group for organizing and managing resources.
az group create --location westeurope --resource-group demo-weu-rgGenerates SSH RSA keys for secure communication.
ssh-keygen -t rsaDeploys an AKS cluster with specified configurations.
az aks create \
--location westeurope \
--subscription <Your-Subscription-ID> \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--ssh-key-value $HOME/.ssh/id_rsa.pub \
--network-plugin kubenet \
--load-balancer-sku standard \
--outbound-type loadBalancer \
--node-vm-size Standard_B2s \
--node-count 1 \
--tags 'ENV=Demo' 'OWNER=Corporation Inc.'Retrieves and merges the AKS cluster's kubeconfig into the local environment.
az aks get-credentials \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--adminImplement a Persistent Volume Claim (PVC) for Azure Disk and mount it within a pod.
kubectl apply -f files/pvc-azure-managed-disk.yaml
kubectl apply -f files/pod-disk.yamlVerify that the PVC is bound and the Pod is running.Ensure the PVC is in a Bound state and the Pod is in a Running state.
kubectl get pvc
kubectl get podsEnter the Pod to verify if the Azure Disk is mounted correctly. Replace <pod-name> with the actual name of your Pod.
kubectl exec -it <pod-name> -- /bin/bashInside the Pod, check if the Azure Disk is mounted:
df -hSet up Persistent Volume Claims (PVCs) for Azure File and mount them in respective pods.
kubectl apply -f files/pvc-azurefile-001.yaml
kubectl apply -f files/pvc-azurefile-002.yaml
kubectl apply -f files/pod-file-001.yaml
kubectl apply -f files/pod-file-002.yamlVerify that the PVCs are bound, and the Pods are running. Ensure the PVCs are in a Bound state, and the Pods are in a Running state.
kubectl get pvc
kubectl get podsEnter the Pods to verify if the Azure Files are mounted correctly. Replace <pod-file-001-name> and <pod-file-002-name> with the actual names of your Pods.
kubectl exec -it <pod-file-001-name> -- /bin/bash
kubectl exec -it <pod-file-002-name> -- /bin/bashInside the Pods, check if the Azure Files are mounted
df -hDeletes the resource group and associated resources.
az group delete -n demo-weu-rg --yes --no-wait