Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 773
Souvik Dey Avatar asked Apr 13 '20 12:04

Souvik Dey


2 Answers

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.

like image 98
Arghya Sadhu Avatar answered Sep 19 '22 07:09

Arghya Sadhu


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?

like image 28
Nick Avatar answered Sep 19 '22 07:09

Nick