liveBook · Manning

StorageClass

As explained in Kubernetes in Action, Second Edition

A StorageClass is a Kubernetes API resource that defines a category of storage, its provisioner, and parameters for dynamically creating volumes in that category.

A StorageClass names a category of persistent storage available in a Kubernetes cluster. It specifies a provisioner and parameters for creating volumes in that category. When an application needs persistent storage, it requests a PersistentVolumeClaim (PVC), which can name a StorageClass; the pod then uses the claim rather than referring directly to a PersistentVolume. section 10.2.5 section 10.1.1

Choose a class for a claim

Run `kubectl get sc` to see available classes and identify one marked `(default)`. A PVC can request a specific class with `spec.storageClassName: premium-rwo`, alongside its storage request and access mode. If the field is omitted, the cluster uses its default class, if one exists. A claim naming a nonexistent class stays Pending; `kubectl describe` on the claim shows repeated ProvisioningFailed events. section 10.2.1

$ kubectl get sc standard-rwo -o yaml     #1
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    components.gke.io/component-name: pdcsi
    components.gke.io/component-version: 0.21.32
    components.gke.io/layer: addon
    storageclass.kubernetes.io/is-default-class: "true"     #2
  creationTimestamp: "2025-07-07T07:31:57Z"
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
    k8s-app: gcp-compute-persistent-disk-csi-driver
  name: standard-rwo
  resourceVersion: "1751873517609007007"
  uid: 6a6a1c0c-48e7-4c10-ab3c-63ad23e0a9a3
parameters:                                    #3
  type: pd-balanced                            #3
provisioner: pd.csi.storage.gke.io     #4
reclaimPolicy: Delete              #5
volumeBindingMode: WaitForFirstConsumer      #6

The inspected `standard-rwo` class shows the provisioner, a parameter passed to it, the default-class annotation, a reclaim policy, and a volume binding mode. section 10.2.5

The binding mode determines when a volume is provisioned and bound to its claim. `Immediate` does this when the PVC is created. `WaitForFirstConsumer` waits for a pod that uses the claim. Classes can also differ in storage technology and supported access modes, such as ReadWriteOnce and ReadWriteMany. section 10.2.5

Represent a manually provided local volume

A local class can use `provisioner: kubernetes.io/no-provisioner` because its storage is provided manually, not dynamically created. Set `volumeBindingMode: WaitForFirstConsumer` so binding waits until the pod is scheduled. Create a separate local PersistentVolume that names this class and identifies the node and path holding the storage. section 10.3.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains fields through inspected YAML and contrasts binding modes; demonstrates a local class without detailing CSI driver internals.
Examples
Uses kubectl class listings, a claim requesting premium-rwo, inspected GKE class YAML, and a manually provided local volume.
What it assumes
Introduces claims and volumes before StorageClass details; uses a cluster with a default class for the simplest claim.
What you can do after
Operate/configure it by inspecting classes, selecting one in a claim, or defining a class for manually provided local storage.
How it connects
Links PersistentVolumeClaims and PersistentVolumes to CSI drivers, provisioners, access modes, and volume binding modes.

Also explained in

Compare how 4 books explain StorageClass →

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.