liveBook · Manning

StorageClass

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A storage class is a Kubernetes object that describes a class of storage and supports dynamic storage provisioning.

A StorageClass is a profile for a class of Kubernetes storage, such as local or cloud storage. It lets an application request persistent storage through a PersistentVolumeClaim (PVC) without an administrator first creating a matching PersistentVolume (PV). The class groups similar storage; its name does not change the underlying storage’s capabilities. section 7.3 section 7.5

To use an existing class:

  • Run `kubectl get sc` to find its name and check its provisioner, reclaim policy, and volume binding mode. Do not assume every cluster has the same precreated class. section 7.3
  • Create a PVC with `storageClassName` set to that class and the requested capacity. Apply the PVC with `kubectl apply -f newpvc.yaml`; you do not need to create its PV separately. section 7.3 section 7.5
  • Mount the claim in a pod or Deployment, then run `kubectl get pvc,pv` to verify that the claim is Bound and a PV exists. section 7.3

Request storage for a Deployment

An exam-style task requests a 1 GiB PVC named `claim-03833` from the existing `standard` class, then mounts it in a Deployment container at `/var/lib/mysql`. If `kubectl get pvc` initially shows Pending, check the class’s binding mode before treating it as a failure. With `WaitForFirstConsumer`, the volume waits until a pod uses the claim. After creating the consumer, check `kubectl get pvc,pv` for the Bound claim and automatically provisioned 1 GiB PV. section 7.3

root@kind-control-plane:/# kubectl get sc standard -o yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
  creationTimestamp: "2025-07-14T21:10:24Z"
  name: standard
  resourceVersion: "264"
  uid: 6caa1035-1584-4356-a060-90c923293a3b
provisioner: rancher.io/local-path
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

Inspect the `standard` class with `kubectl get sc standard -o yaml`. Its provisioner, `Delete` reclaim policy, and `WaitForFirstConsumer` binding mode show settings applied to automatically provisioned PVs. section 7.3.1

For practice, create a `node-local` StorageClass using `kubernetes.io/no-provisioner` and `WaitForFirstConsumer`, then create a `ReadWriteOnce` PVC and a pod that mounts it. Keep this exercise distinct from using an existing class to dynamically provision a PV: the specified provisioner is `no-provisioner`. section 7.3.1

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Works through class inspection, PVC selection, delayed binding, and PV verification; stops short of provisioner internals.
Examples
Uses a `standard` class, a 1 GiB claim mounted at `/var/lib/mysql`, and a `node-local` practice exercise.
What it assumes
Assumes familiarity with PVs, PVCs, pods, and Deployments while defining the StorageClass profile and showing how to inspect it.
What you can do after
Apply it via kubectl by selecting an existing class in a PVC, mounting the claim, and verifying its PV.
How it connects
Connects PersistentVolumeClaims, PersistentVolumes, provisioners, reclaim policies, volume binding modes, and pod mounts.

Also explained in

Compare how 4 books explain StorageClass →

Related concepts

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