Howto migrate AKS CSI StorageClass from LRS to ZRS

Kirrane, Desmond (Dessie) 20 Reputation points
2023-03-30T10:30:52.92+00:00

Is it possible to migrate a StorageClass from LRS CSI StorageClass to ZRS?

Likewise migrate PVs/PVCs to ZRS?

If so, what would be the process?

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,999 questions
{count} votes

Accepted answer
  1. Andrei Barbu 2,581 Reputation points Microsoft Employee
    2023-03-30T10:45:08.58+00:00

    Hello Kirrane, Desmond (Dessie)

    If it is an AKS-managed StorageClass, it is not recommended to change it.

    To identify an AKS-managed StorageClass, you can generate its yaml (kubectl get sc <sc-name> -o yaml) and look for label "addonmanager.kubernetes.io/mode"

    To modify your existing StorageClass to use ZRS, you can use the below:

    parameters:
      skuName: Standard_ZRS
    

    You can also create a new StorageClass with ZRS.

    You can refer to the below example and adapt it as needed:

    allowVolumeExpansion: true
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: azurefile-csi-zrs
    mountOptions:
    - mfsymlinks
    - actimeo=30
    - nosharesock
    parameters:
      skuName: Standard_ZRS
    provisioner: file.csi.azure.com
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      creationTimestamp: "2023-03-07T08:28:21Z"
      labels:
        addonmanager.kubernetes.io/mode: EnsureExists
        
      name: azurefile-csi
      resourceVersion: "361"
      uid: d37b01e9-c284-405a-8539-1fab044571a6
    mountOptions:
    - mfsymlinks
    - actimeo=30
    - nosharesock
    parameters:
      skuName: Standard_LRS
    provisioner: file.csi.azure.com
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    allowVolumeExpansion: true
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: azurefile-csi-zrs
    mountOptions:
    - mfsymlinks
    - actimeo=30
    - nosharesock
    parameters:
      skuName: Standard_ZRS
    provisioner: file.csi.azure.com
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    

    Note there is also the Premium_ZRS option

    To migrate, you may want to use the snapshot feature. Reference links for Azure Disk and Azure File:

    https://learn.microsoft.com/en-us/azure/aks/azure-files-csi#create-a-custom-storage-class
    https://learn.microsoft.com/en-us/azure/aks/azure-disk-csi#volume-snapshots

    Please make sure to test on some test resources as I personally didn't implement this scenario, but it is possible to be achievable using volume snapshots.


    I hope this is helpful. If any clarification needed, let me know and I will do my best to answer.

    Please "Accept as Answer" and Upvote if it helped, so that it can help others in the community looking for help on similar topics.

    Thank you!

    0 comments No comments

0 additional answers

Sort by: Most helpful