Home › CKA practice tasks › Provision and inspect a CSI volume
CKA · Cluster Architecture, Installation & Configuration

Create a CSI StorageClass and Trace the Provisioned Volume

The sample CSI hostpath driver is installed in this dedicated training cluster. Its registered name is `hostpath.csi.k8s.io`. Namespace `csi-work` and a ready-to-apply Pod manifest `/root/writer.yaml` are provided. The driver is a teaching fixture for this single-node cluster.

Live lab access

This task description is public. Its live lab requires full access; six other CKA labs are available in Free Practice with AI Lab Coach.

Create an account to continue →

Explore the six free labs with AI Lab Coach →

Read the brief on any device. Use a desktop or laptop for the terminal lab. Nothing starts until you choose Start.

The task

The sample CSI hostpath driver is installed in this dedicated training cluster. Its registered name is hostpath.csi.k8s.io. Namespace csi-work and a ready-to-apply Pod manifest /root/writer.yaml are provided. The driver is a teaching fixture for this single-node cluster.

Requirements
1. Create StorageClass csi-retain using the installed CSI driver, reclaim policy Retain, and binding mode Immediate.
2. In csi-work, create PVC work-data requesting 100Mi, access mode ReadWriteOnce, from csi-retain.
3. Apply /root/writer.yaml. Ensure its Pod runs with the claim mounted at /data and /data/proof.txt contains durable.
4. Inspect the dynamically provisioned PV and write only its CSI driver name to /root/volume-driver.txt.

Do not create a static PV or replace the PVC volume with hostPath or emptyDir.

Original Prepium guide · Written for Kubernetes v1.35 and checked against the official documentation on 6 October 2026. Use a disposable practice cluster. You need at least one CSI driver installed; kubectl get csidrivers must list something before the steps below can provision anything.

From StorageClass to CSI driver: how dynamic provisioning picks its storage

A CSI driver is storage code that runs outside Kubernetes and plugs in through the Container Storage Interface. Kubernetes never talks to it directly from your claim: the claim names a StorageClass, the class names the driver in its provisioner field, and the driver creates a volume that comes back as a PersistentVolume carrying spec.csi.driver. Knowing that chain lets you build a class quickly and prove which backend actually holds the data.

PVC (storageClassName) ──→ StorageClass (provisioner, reclaimPolicy, volumeBindingMode)
                                   │ asks the CSI driver for a volume
PV  (spec.csi.driver, spec.csi.volumeHandle, persistentVolumeReclaimPolicy) ──→ bound to the PVC

1. Find the installed driver names

kubectl get csidrivers
kubectl get storageclass
DRIVER=$(kubectl get csidrivers -o jsonpath='{.items[0].metadata.name}'); echo "$DRIVER"

CSIDriver objects are cluster-scoped and named after the driver's own reported name. Registering one is optional, so if the list is empty, read the driver's documentation instead. That exact string is what a StorageClass needs as its provisioner, so copy it rather than typing it from memory. If several drivers are listed, pick one deliberately instead of trusting items[0].

2. Create a class and a claim

kubectl create namespace prepium-tutorial
cat <<EOF | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: tutorial-csi
provisioner: $DRIVER
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: notes
  namespace: prepium-tutorial
spec:
  storageClassName: tutorial-csi
  accessModes: ["ReadWriteOnce"]
  resources:
    requests:
      storage: 64Mi
EOF
kubectl -n prepium-tutorial get pvc notes

The claim sits in Pending, which is expected here. WaitForFirstConsumer delays binding and provisioning until a Pod that uses the claim exists, so the volume can be placed where that Pod is scheduled. With Immediate (the default when the field is omitted) the volume is created as soon as the claim is. Some drivers also expect parameters; check your driver's documentation if provisioning stalls.

3. Give it a consumer, then trace the volume

kubectl -n prepium-tutorial run notes-writer --image=busybox:1.36 --restart=Never \
  --overrides='{"spec":{"containers":[{"name":"w","image":"busybox:1.36","command":["sh","-c","echo kept > /notes/a.txt; sleep 3600"],"volumeMounts":[{"name":"v","mountPath":"/notes"}]}],"volumes":[{"name":"v","persistentVolumeClaim":{"claimName":"notes"}}]}}'
kubectl -n prepium-tutorial wait --for=jsonpath='{.status.phase}'=Bound pvc/notes --timeout=120s
PV=$(kubectl -n prepium-tutorial get pvc notes -o jsonpath='{.spec.volumeName}')
kubectl get pv "$PV" -o jsonpath='{.spec.csi.driver}{"\n"}{.spec.csi.volumeHandle}{"\n"}{.spec.persistentVolumeReclaimPolicy}{"\n"}'
kubectl -n prepium-tutorial exec notes-writer -- cat /notes/a.txt

The claim's spec.volumeName is the authoritative link to its PV. On that PV, spec.csi.driver names the driver that created it and volumeHandle is the backend's own identifier. The reclaim policy was copied from the class when the PV was created.

4. Watch the reclaim policy act

kubectl -n prepium-tutorial delete pod notes-writer
kubectl -n prepium-tutorial delete pvc notes
kubectl get pv "$PV"

With Delete the PV and its backing storage are removed, so the last command soon reports NotFound. Had the class used Retain, the PV would move to Released, keep its data and refuse new claims until an administrator cleans it up by hand. That is the trade: Retain protects data from an accidental claim deletion at the cost of manual housekeeping.

Common mistakes

Example checkEvidence
Class points at a real driverPROVISIONER column matches a name from kubectl get csidrivers
Claim is satisfied dynamicallyPVC Bound; spec.volumeName names a PV nobody created by hand
PV came from CSIspec.csi.driver and spec.csi.volumeHandle are set on the PV
Policy as intendedRECLAIM POLICY column of kubectl get pv

Cleanup: kubectl delete namespace prepium-tutorial and kubectl delete storageclass tutorial-csi. References: Storage Classes, Persistent Volumes, CSI volumes. Next, try default StorageClass handling or binding a claim to a specific PV.

Difficulty
Medium · 8 minutes target
Domain
Cluster Architecture, Installation & Configuration
Grading
Live checks · partial credit

Practice scope

This additional curriculum lab is available in single-task practice with the existing 12-minute limit. Its alternate scenario also appears in one of the two mixed curriculum mocks. The first three 17-task mocks keep their original task sets. Hints, an explained solution and requirement-by-requirement feedback are available in the lab.

Browse CKA practice tasks →