If you deployed a private volume claim using the managed-premium storage class, then ran out of space and now you are searching how to expand the disk to a larger disk, this is how you can do it from scratch:

manage-premium storage class is a premium storage class that allows volume expansion: allowVolumeExpansion: true.

Create a private volume claim using a managed-premium storage class:

Create a pvc.yaml file with the following contents:

 1apiVersion: v1
 2kind: PersistentVolumeClaim
 3metadata:
 4  name: nginx-pvc
 5spec:
 6  accessModes:
 7    - ReadWriteOnce
 8  resources:
 9    requests:
10      storage: 128Gi
11  storageClassName: managed-premium

and deploy it to your cluster:

1kubectl apply -f pvc.yaml

Create a deployment that uses the PVC:

Create a deployment.yaml file with the following contents:

 1apiVersion: apps/v1
 2kind: Deployment
 3metadata:
 4  name: nginx
 5  labels:
 6    app: nginx
 7spec:
 8  replicas: 1
 9  selector:
10    matchLabels:
11      app: nginx
12  template:
13    metadata:
14      labels:
15        app: nginx
16    spec:
17      containers:
18      - name: nginx
19        image: nginx
20        volumeMounts:
21        - mountPath: "/mnt/azure"
22          name: volume
23      volumes:
24        - name: volume
25          persistentVolumeClaim:
26            claimName: nginx-pvc

and deploy it to your cluster:

1kubectl apply -f deployment.yaml

Check the PVC status:

To check the status of the PVC, run the following command:

1kubectl get pvc -w

Create a test file by running the following command:

1kubectl exec -it $(kubectl get po -l "app=nginx" -o name) -- sh -c "echo 'Very important file' > /mnt/azure/test.file"

Resize the PVC and expand the disk:

Scale the deployment to 0 replicas:

1kubectl scale --replicas=0 deployment nginx

Check the status of the attached disk:

1$resourceGroupName="<your aks resource group>"
2$aksName="<your aks name>"
3$resourceGroup=$(az aks show --resource-group $resourceGroupName --name $aksName --query "nodeResourceGroup" --output tsv)
4az disk list --resource-group $resourceGroup --query "[[0].diskState, [0].diskSizeGb]"

You should get the following result:

1[
2  "Unattached",
3  256
4]

Note: I only had one disk attached to the AKS cluster, so I am using the first disk.

Resize the PVC:

 1apiVersion: v1
 2kind: PersistentVolumeClaim
 3metadata:
 4  name: nginx-pvc
 5spec:
 6  accessModes:
 7    - ReadWriteOnce
 8  resources:
 9    requests:
10      storage: 256Gi
11  storageClassName: managed-premium
12  volumeName: nginx-pv

and deploy it to your cluster:

1kubectl apply -f pvc.yaml

Scale the deployment back to 1 replicas:

1kubectl scale --replicas=1 deployment nginx

and check the po status:

1kubectl get po -w

Check the size of the disk:

Check again the status and size of the attached disk:

1$resourceGroupName="<your aks resource group>"
2$aksName="<your aks name>"
3$resourceGroup=$(az aks show --resource-group $resourceGroupName --name $aksName --query "nodeResourceGroup" --output tsv)
4az disk list --resource-group $resourceGroup --query "[[0].diskState, [0].diskSizeGb]"

You should get the following result:

1[
2  "Attached",
3  256
4]

and finally check the contents of the test file:

1kubectl exec $(kubectl get po -l "app=nginx" -o name) -- sh -c "cat /mnt/azure/test.file"

Hope it helps!!!