11

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
  • 653
  • 1
  • 9
  • 18
  • 1
    do we speak about https://kubernetes.io/docs/concepts/storage/storage-classes/#gce-pd `type` field? – Nick Apr 14 '20 at 15:15
  • That's right @Nick – Souvik Dey Apr 14 '20 at 15:24
  • Stash can be helpful to backup PVCs and restore the data to new PVCs with the desired storage class. https://www.objectif-libre.com/en/blog/2020/01/10/kubernetes-backup-stateful-apps/ – VAS Apr 20 '20 at 15:48

2 Answers2

12

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
  • 41,002
  • 9
  • 78
  • 107
3

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
  • 1,882
  • 11
  • 16
  • I want to change the `storageClassName` of the PV. @Nick – Souvik Dey Apr 15 '20 at 15:06
  • 2
    in order for storage to be provisioned properly, the storage class needs to changed on PV and PVC. Unfortunately it's not possible to change it on existing PVC. It'll be needed to create a new PVC and migrate data then. – Nick May 04 '20 at 07:18