Changing k8s Storage Class - Migration Job
I’m setting up longhorn in my homelab [1], and I ran into an issue where I
initially setup some pvcs under longhorn, and later realized that to get
longhorn to snapshot and backup I needed to hand edit volumes after the fact or
change storage class. I’m all in on gitops so option 1 was not an option. So
changing storageclass it is.
Now the issue is that you CANNOT mutate storageclass on a provisioned pvc, it
is an immutable attribute.
Migration Job # [2]
This migration job will create a new pvc with the new storageclass and move the
data from the old pvc to the new pvc.
Existing Pods
This migration job will not work if you have a pod using the old pvc. You
will need to shutdown the pod and delete it.
# old pvc with longhorn storageclass
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: site-pvc-longhorn
namespace: waylonwalker-com
spec:
storageClassName: longhorn-backup
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
# new pvc with longhorn-ba...