Jeff Cloud Systems Architect
1 min read

Convert AKS PV to Premium Disk

Convert AKS PV to Premium Disk

Convert AKS PV to Premium Disk

AKS Clusters have a few pre-defined storage classes that can be used when creating volumes. These are typically:

NAME                PROVISIONER                RECLAIMPOLICY   
azurefile    Delete
azurefile-premium   Delete
default (default)   Delete
managed-premium   Delete

If you inspect each of these, you will find the following:

NameDisk TypeSKU
azurefileAzure File StorageStandard_LRS
azurefile-premiumAzure File StoragePremium_LRS
defaultAzure Managed Disk (Standard SSD)StandardSSD_LRS
managed-premiumAzure Managed Disk (Premium SSD)Premium_LRS
Note: Premium storage is only available on VMs with an s in the name. E2a_v4 does not support premium, E2as_v4 does

If you need to upgrade your storage class from StandardSSD to Premium, this is how

First, ensure your PV is set to Retain, otherwise you will lose data!!!!!

kubectl get pv

If your storageclass is set to Delete, you need to patch it

kubectl patch pv <your-pv-name> -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'

Detach PVC

Make sure you have a way to redeploy. Try exporting the yaml before proceeding

In order to upgrade your storage class, you need to release the PVC by deleting whatever is attached. If you're using a deployment, stateful set or daemomset, delete it. Make sure you have a way to re-deploy

kubectl delete deployment test

View/Edit the ClaimRef

PVs use a ClaimRef to allow a PVC to re-bind. You'll want to delete the resourceVersion and uid in the claimRef section to allow a re-bind

kubectl edit pv <your-pv-name>

And delete resourceVersion and uid lines. Do not delete anything else!

    apiVersion: v1
    kind: PersistentVolumeClaim
    name: test-data
    namespace: test
    resourceVersion: "6260544"
    uid: fff2487a-a96f-4659-9878-d191b855db7a

Now, find your disk in the Azure Portal by navigating to the cluster resource group. If you are using VMSS Node Pools, go to the VMSS resource group. Search the list for your PV name and click on the disk

The top right will show the current storage class

Click on Configuration and change the Storage Type, then click save. If this option is grayed out, the disk is still bound, make sure you deleted the deployment.


Re-deploy your yaml and watch the PVC reconnect to the newly upgraded PV

Seriously, make sure you can re-deploy your Kubernetes objects and that the PV is set to retain. I take no responsibility for lost data