Attribute storageClassName in PersistentVolume

5/27/2020
  1. Is it possible define storageClassName in PersistentVolume although not exists corresponding StorageClass in the cluster?
  2. Suppose that there are : StorageClass with name = X, pre-defined PersistentVolume with storageClassName = X, PersistentVolumeClaim with storageClassName = X. In this case the cluster will try bind the PVC to the existing PV and dynamic provisioning will happen only if the PV is not available?
-- Mortova
kubernetes

1 Answer

5/27/2020

From the docs

When none of the static PVs the administrator created match a user’s PersistentVolumeClaim, the cluster may try to dynamically provision a volume specially for the PVC. This provisioning is based on StorageClasses: the PVC must request a storage class and the administrator must have created and configured that class for dynamic provisioning to occur.

  1. PV can be created with a storage class which does not exist. You can then create a PVC which need to match with the storageClassName in the PV. There is no requirement for the storage class to exist in the cluster when the provisioning is not dynamic.
  2. When None of the PV matches with PVC then dynamic provisioning happens. For the dynamic provisioning to be successful existence of the storage class in the cluster is needed as mentioned in the PVC in storageClassName.
-- Arghya Sadhu
Source: StackOverflow