How do I change the storage class of existing persistent volumes?

4/13/2020

I have a bunch of standard PVs bound to PVCs in Kubernetes running in Google Kubernetes Engine. I want to change their storage class to SSD. How do I achieve that?

-- Souvik Dey
google-kubernetes-engine
kubernetes
persistent-volume-claims
persistent-volumes

2 Answers

4/13/2020

No it's not possible to change the storage class of an existing PVC.You will have to create a new PVC with desired storage class and then delete the existing one.

-- Arghya Sadhu
Source: StackOverflow

4/14/2020

If I understood you correctly, you would like to change a type for your PVs, and the question is not "if" but "where".

The relations between PVC, PV and StorageClass is very simple.

PVC is just request for a storage of particular type (specified under storageClassName ) and size (that is listed in PV) .

kind: PersistentVolumeClaim
spec:
...
  resources:
    requests:
      storage: 8Gi
  storageClassName: slow

PV has storageClassName in spec: .

kind: PersistentVolume
...
spec:
  capacity:
    storage: 10Gi
...
  storageClassName: slow

The storageClass has type .

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: slow
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  fstype: ext4
  replication-type: none

# type: pd-standard or pd-ssd. Default: pd-standard

Is it the info you've been looking for?

-- Nick
Source: StackOverflow