Dynamic storage provisioning is a key part of scaling applications. When a storage class is not specified by a PVC, Kubernetes uses the default option. Let's perform the following steps to set our preferred storage class as the default:
- Let's set the existing default storage class as the non-default option:
$ kubectl patch storageclass default -p '{"metadata": {"annotations":{"storageclass.beta.kubernetes.io/is-default-class":"false"}}}'
- Now, define azure-zrs as the default storage class again:
$ kubectl patch storageclass azure-zrs -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
- Confirm the new default storage class. You should see new azure-zrs as the default, similar to the following output:
$ kubectl get sc
NAME PROVISIONER AGE
azure-zrs (default) kubernetes.io/azure-disk 4m38s
default kubernetes.io/azure-disk 23m
managed-premium kubernetes.io/azure-disk 23m
Now you know how to set your preferred storage class as the default on your AKS cluster.