liveBook · Manning

Storageclassname

As explained in Kubernetes in Action, Second Edition

The storageClassName field is the PersistentVolumeClaim field that selects the StorageClass from which its requested persistent storage should be provisioned.

storageClassName is the PersistentVolumeClaim field that selects the StorageClass used to provision requested persistent storage. A cluster may offer several classes for different performance, access-mode, or storage-backend needs; one is usually marked as the default. section 10.2.5

Selecting a storage class

A claim that sets storageClassName to standard-rwo uses that StorageClass's provisioner and parameters to create a PersistentVolume. Inspect available classes with kubectl get sc. If the field is omitted, Kubernetes uses the default StorageClass. section 10.2.5 section 10.4.3

$ kubectl get sc
NAME                        PROVISIONER                    RECLAIMPOLICY
enterprise-multishare-rwx   filestore.csi.storage.gke.io   Delete
enterprise-rwx              filestore.csi.storage.gke.io   Delete
premium-rwo                 pd.csi.storage.gke.io          Delete
premium-rwx                 filestore.csi.storage.gke.io   Delete
standard                    kubernetes.io/gce-pd           Delete
standard-rwo (default)      pd.csi.storage.gke.io          Delete
standard-rwx                filestore.csi.storage.gke.io   Delete
zonal-rwx                   filestore.csi.storage.gke.io   Delete

Compare available StorageClasses, their provisioners, and the class marked as default. section 10.2.5

Keep these operational distinctions in mind:

  • Changing storageClassName is not supported after PersistentVolumeClaim creation; switching classes requires creating a new claim. section 10.4.1
  • The selected StorageClass also determines whether the bound volume can be expanded; existing claims can be enlarged but not reduced. section 10.4.1
  • A StorageClass may delay provisioning until a pod first references the claim when it uses WaitForFirstConsumer. section 10.2.5

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains selection, defaulting, provisioners, binding timing, expansion, and immutability rather than implementation internals.
Examples
Uses kubectl get sc, a standard-rwo claim, and a snapshot-restored claim with the default class.
What it assumes
Assumes familiarity with PersistentVolumeClaims and PersistentVolumes while introducing StorageClasses, provisioners, and default selection.
What you can do after
Operate/configure PersistentVolumeClaims with an explicit or default StorageClass and recognize replacement requirements.
How it connects
Connects PersistentVolumeClaim, StorageClass, PersistentVolume, volume provisioner, default StorageClass, and VolumeSnapshot.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.