This tutorial guides you on migrating Persistent Volumes (PVs) from the gp2 storageClass to the new default gp3 storageClass. Before implementing this process in production, it is advisable to perform a thorough test in a testing environment.
Important:
The migration process includes PVC removal and heavily relies on replication between brokers. Before beginning, validate that there are no errors or warnings.
To avoid data loss, ensure all critical stations with data are configured with at least 3 replicas.
Every step should be executed with continuous log monitoring, paying extra attention to the replication process during the broker startup.
Step 1: Create a new storageClass.yaml file with the required configuration.
Begin by applying the configuration for the new storageClass:
kubectlapply-fstorageClass.yaml
Step 3:Edit the Old StorageClass Configuration
Edit the old storageClass to change it from the default setting. In this example, the old storageClass is named "gp2."
kubectl edit storageclasses.storage.k8s.io gp2
Make the following change in the configuration:
apiVersion:storage.k8s.io/v1kind:StorageClassmetadata:annotations:kubectl.kubernetes.io/last-applied-configuration:| {"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"},"name":"gp2"},"parameters":{"fsType":"ext4","type":"gp2"},"provisioner":"kubernetes.io/aws-ebs","volumeBindingMode":"WaitForFirstConsumer"}
storageclass.kubernetes.io/is-default-class: "false" ## Change from "true" to "false"creationTimestamp:"2022-02-01T12:07:20Z"labels:k8slens-edit-resource-version:v1name:gp2resourceVersion:"214718038"uid:5c09a9e5-06a4-4436-bda0-250b279e0475parameters:fsType:ext4type:gp2provisioner:kubernetes.io/aws-ebsreclaimPolicy:DeletevolumeBindingMode:WaitForFirstConsumer
Delete the PVC (data-memphis-metadata-0) associated with the old storageClass. The pod itself will also be deleted, resulting in a new PVC assigned to the new storageClass
Ensure the metadata finishes the sync process before going to the next pod.