Override StorageClass parameters from a PVC

2/12/2019

This may be a basic question but I haven't seen any documentation on it.

Can you override parameters defined within the StorageClass using the PVC?

For example, here is a StorageClass I have created:

---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: sc-gold
provisioner: hpe.com/hpe
parameters:
  provisioning: 'full'
  cpg: 'SSD_r6'
  snapcpg: 'FC_r6'

PVC

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvc-nginx
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: sc-gold

I want to use the "sc-gold" StorageClass as defined above but be able to override/change the provisioning type from "full" to "thin" when creating the PVC without having to create another StorageClass. I don't see any examples of how the PVC would be formatted or if this is even supported within the spec.

Traditionally as Storage Admins, we create the StorageClass as storage "profiles" and then the users are assigned/consume the SC in order to create volumes, but is there any flexibility in the spec? I just want to limit the StorageClass sprawl that I can see happening in order to accommodate any and all scenarios.

Thoughts?

-- Budhac
kubernetes
kubernetes-pvc
storage

1 Answer

2/12/2019

No. you cant override storage class params during PVC creation. you might need to create additional storageClass and map the required storageClass to the PVC.

-- P Ekambaram
Source: StackOverflow