How to change storage class
search cancel

How to change storage class

book

Article ID: 390224

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid Integrated Edition

Issue/Introduction

This article explains how to change the Storage Class for a Persistent Volume.

Resolution

  1. Create configmap in velero namespace, need to specif old and new storage class

    apiVersion: v1
    kind: ConfigMap
    metadata:
      # any name can be used; Velero uses the labels (below)
      # to identify it rather than the name
      name: change-storage-class-config
      # must be in the velero namespace
      namespace: velero
      # the below labels should be used verbatim in your
      # ConfigMap.
      labels:
        # this value-less label identifies the ConfigMap as
        # config for a plugin (i.e. the built-in restore item action plugin)
        velero.io/plugin-config: ""
        # this label identifies the name and kind of plugin
        # that this ConfigMap is for.
        velero.io/change-storage-class: RestoreItemAction
    data:
      # add 1+ key-value pairs here, where the key is the old
      # storage class name and the value is the new storage
      # class name.
      <old-storage-class>: <new-storage-class>


  2. Take a backup using velero
    velero backup <backup name> --include-namespaces=<namespace>
  3. Scale down the deployment
    kubectl scale deployment <Deployment name> --replicas=0

     

  4. Delete the PVC (Check the Retain policy on PV, if its Delete, then the PV will be deleted. Important to verify that backup is successful in this scenario)
    kubectl delete pvc <PVC name>

     

  5. Restore from backup
    velero restore create --from-backup <Backup name>

     

  6. Scale the deployment
    kubectl scale deployment <Deployment name> --replicas=X

 

Note: This procedure will involve pod downtime between steps 3 and 6.

Additional Information

Velero docs which shows how to change the Storage Class on restoration.