# Kubernetes Storage: PV, PVC, StorageClass and CSI

> How PersistentVolumes, PersistentVolumeClaims and StorageClasses bind, static and dynamic provisioning, the CSI architecture and flow, dynamic provisioning of local disks with TopoLVM, and on to NetApp Trident, S3 object storage and COSI

- URL: https://lcxlab.com/en/post/cka-storage
- Author: Miles Hsu
- Published: 2026-11-05
- Category: DevOps
- Series: Certified Kubernetes Administrator (CKA) #7
- Tags: CKA, Kubernetes, CSI, TopoLVM
- License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/deed.en)

---

Storage is 10% of the CKA. Typical tasks: create a PV and PVC and use it in a Pod, create a StorageClass, expand a PVC, and figure out why a PVC is stuck in `Pending`. This post covers how PVs, PVCs and StorageClasses relate, then looks at CSI, which powers dynamic provisioning, and finally walks through it hands-on with TopoLVM.

Before starting, the background post is recommended:

[Linux Storage Basics: Block, File and Object Storage, and LVM](https://lcxlab.com/en/post/storage-basics-block-file-object)

---

## Starting with volumes

A container's file system is temporary: anything written inside is gone when the container restarts. A Pod's `volumes` let containers mount storage from outside the container. Some types common on the CKA:

| Type | Lifetime | Use |
| --- | --- | --- |
| `emptyDir` | Tied to the Pod, cleared when the Pod is deleted | Scratch files shared by containers in one Pod |
| `hostPath` | Tied to the Node | Reading files on the Node (such as logs), or single-node testing |
| `configMap` / `secret` | Tied to the object | Mounting config files and certificates as files |
| `persistentVolumeClaim` | Independent of the Pod | Data that must be kept |

The first three are written directly into the Pod. The last gets storage indirectly through a PVC, and it is the focus of this post.

---

## PV, PVC and StorageClass

Separating "the storage" from "who uses it" is the core of Kubernetes storage design:

| Object | Scope | Created by | Meaning |
| --- | --- | --- | --- |
| PersistentVolume (PV) | Cluster | An admin, or automatically through a StorageClass | A piece of storage that actually exists |
| PersistentVolumeClaim (PVC) | Namespace | A user | "I need this much space with this access mode" |
| StorageClass | Cluster | An admin | A template for "how to create PVs automatically" |

A Pod only knows about the PVC; it doesn't need to know whether the storage underneath is a local disk, NFS or a cloud disk.

### Static provisioning: creating PVs by hand

The admin creates a PV first:

```yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-log
spec:
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: manual
  hostPath:
    path: /pv/log
```

The user creates a PVC:

```yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: claim-log
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: manual
  resources:
    requests:
      storage: 50Mi
```

```bash
kubectl apply -f pv.yaml -f pvc.yaml
kubectl get pv,pvc
```

The PVC finds a matching PV and binds to it (`Bound`). The conditions are:

- Same `storageClassName` (if neither sets one, the PVC gets the default StorageClass, a common trap).
- Matching `accessModes`.
- PV capacity ≥ the capacity the PVC requests. In the example the PVC asks for 50Mi and binds to a 100Mi PV, so `kubectl get pvc` shows 100Mi.
- If there is a `selector`, the PV's labels must match.

A PV binds to only one PVC, and any leftover space is not shared with anyone else.

A Pod uses the PVC:

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: webapp
spec:
  containers:
    - name: app
      image: nginx
      volumeMounts:
        - name: log
          mountPath: /var/log/nginx
  volumes:
    - name: log
      persistentVolumeClaim:
        claimName: claim-log
```

>[!TIP] 💡 There is no `kubectl create pv` in the exam
>`kubectl create` has no generator for PVs or PVCs. In the exam, the fastest way is to copy the YAML from the official page "Configure a Pod to Use a PersistentVolume for Storage" and edit it.

### accessModes

| Mode | Short | Meaning |
| --- | --- | --- |
| ReadWriteOnce | RWO | Mounted read-write by **one Node** (several Pods on that Node can all use it) |
| ReadOnlyMany | ROX | Mounted read-only by many Nodes |
| ReadWriteMany | RWX | Mounted read-write by many Nodes; needs file storage such as NFS or CephFS |
| ReadWriteOncePod | RWOP | Mounted read-write by **one Pod** only; CSI volumes only |

Local disks and cloud block storage usually support only RWO; RWX needs file storage.

### reclaimPolicy and PV status

What happens to a PV after its PVC is deleted depends on `persistentVolumeReclaimPolicy`:

- **Retain:** the PV and its data are kept, the status becomes `Released`, and it is not bound to a new PVC automatically. The default for PVs created by hand.
- **Delete:** the underlying storage is deleted too. The default for PVs created dynamically by a StorageClass.
- **Recycle:** wipes the data and makes the PV `Available` again; deprecated.

PV status: `Available` (unbound) → `Bound` → `Released` (PVC deleted, data still there). `Failed` means automatic reclamation failed.

>[!TIP] 💡 Making a Released PV usable again
>A `Released` PV still remembers the old PVC (`spec.claimRef`), so it won't be bound again. Once you've confirmed the data can be reused, removing `claimRef` returns it to `Available`:
>`kubectl patch pv pv-log --type json -p '[{"op":"remove","path":"/spec/claimRef"}]'`

### Dynamic provisioning: StorageClass

Having an admin create PVs every time is tedious. A StorageClass makes a matching PV appear as soon as a PVC is created:

```yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: topolvm.io
parameters:
  csi.storage.k8s.io/fstype: xfs
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
```

- `provisioner`: which storage plugin creates the volume; today this is almost always the name of a CSI driver.
- `parameters`: passed to the plugin as-is; each plugin defines its own.
- `is-default-class` annotation: used when a PVC doesn't set `storageClassName`.
- `volumeBindingMode`: `Immediate` or `WaitForFirstConsumer`, explained later.
- `allowVolumeExpansion`: whether PVCs may be expanded later.

How the plugin named in `provisioner` works is what CSI is about.

---

## Why CSI?

Early Kubernetes put each vendor's storage code directly into the Kubernetes source, as **in-tree volume plugins**. That caused several problems:

- **Released with Kubernetes:** a storage vendor fixing a bug had to wait for the next Kubernetes release.
- **Code bloat:** kubelet and controller-manager were stuffed with every vendor's SDK.
- **Privilege and stability:** third-party code ran inside core components, so a bug could affect the whole cluster.

So the community defined **CSI (Container Storage Interface)**, moving storage implementations out of Kubernetes itself. It's the same idea as [CNI](https://lcxlab.com/en/post/cni-plugins-for-kubernetes) at the network layer: Kubernetes defines only "what to do" and leaves "how" to plugins.

>[!NOTE] In-tree plugins are being removed
>CSI Migration started in Kubernetes 1.17: calls to in-tree plugins such as `awsElasticBlockStore` and `gcePersistentDisk` are redirected to the matching CSI driver, and the plugins have since been removed from the source one by one. New clusters today use storage through CSI almost exclusively.

---

## What does the CSI spec define?

CSI itself is a gRPC interface spec. It isn't only for Kubernetes: other container platforms such as Nomad can call the same CSI driver.

A CSI driver implements three gRPC services:

| Service | Responsibility | Main RPCs |
| --- | --- | --- |
| Identity | Report the driver's name, version and capabilities | `GetPluginInfo`, `GetPluginCapabilities`, `Probe` |
| Controller | Work that doesn't have to happen on a particular Node: create / delete volumes, attach to Nodes, snapshots, expansion | `CreateVolume`, `DeleteVolume`, `ControllerPublishVolume`, `CreateSnapshot`, `ControllerExpandVolume` |
| Node | Work that must happen on the Pod's Node: formatting, mounting into the Pod's directory | `NodeStageVolume`, `NodePublishVolume`, `NodeExpandVolume`, `NodeGetInfo` |

Taking a volume from "doesn't exist" to "the Pod can read and write it" roughly goes through these stages:

```text
CreateVolume              Create the volume (ask the cloud for an EBS disk, or lvcreate an LV)
  ↓
ControllerPublishVolume   Attach the volume to the Node (e.g. attach EBS to an EC2 instance)
  ↓
NodeStageVolume           Format it on the Node and mount it at a global staging directory
  ↓
NodePublishVolume         Bind mount it into the Pod's volume directory
```

Compare this with the manual LV flow from the background post: `lvcreate` maps to `CreateVolume`, `mkfs` + `mount` map to `NodeStageVolume` / `NodePublishVolume`, `lvextend -r` maps to expansion, and `lvremove` maps to `DeleteVolume`.

Not every driver implements every step. A local LVM volume is already on the Node, so there's nothing to "attach to the Node" and `ControllerPublishVolume` can be skipped; NFS needs no formatting, so `NodeStageVolume` can be skipped too. Drivers report which steps they support through `GetPluginCapabilities` and `NodeGetCapabilities`, and callers only call what is supported.

---

## What does a CSI driver look like in the cluster?

The CSI spec only says which gRPC methods a driver provides; it knows nothing about Kubernetes objects such as PVCs and PVs. The translation in between is done by a set of **sidecar** containers maintained by the Kubernetes community: they watch the Kubernetes API and call the driver over a Unix socket.

So a typical CSI driver is deployed in two parts:

**Controller (usually a Deployment)**

| Container | Watches | Calls |
| --- | --- | --- |
| The driver itself | — | Implements the Identity / Controller services |
| external-provisioner | PVCs | `CreateVolume` / `DeleteVolume`, and creates the PV |
| external-attacher | VolumeAttachments | `ControllerPublishVolume` |
| external-resizer | PVC capacity changes | `ControllerExpandVolume` |
| external-snapshotter | VolumeSnapshots | `CreateSnapshot` |
| livenessprobe | — | `Probe`, exposing a health check endpoint |

**Node (a DaemonSet, one per Node)**

| Container | Purpose |
| --- | --- |
| The driver itself | Implements the Identity / Node services and actually runs mount and mkfs |
| node-driver-registrar | Registers the driver's socket with kubelet |
| livenessprobe | Health check |

There is no sidecar watching Pods on the Node side, because kubelet itself is the CSI caller there: once a Pod is scheduled to the Node, kubelet calls `NodeStageVolume` and `NodePublishVolume` directly over the socket.

How does kubelet find the socket? node-driver-registrar places a registration socket in `/var/lib/kubelet/plugins_registry/`. Through it kubelet learns the driver's name and the path of its actual socket (usually `/var/lib/kubelet/plugins/<driver name>/csi.sock`), and from then on calls that path.

A few related Kubernetes objects:

- **CSIDriver:** declares that the driver exists in the cluster, whether it needs attaching (`attachRequired`), whether it wants Pod information, and so on.
- **CSINode:** one per Node, recording which drivers are registered on that Node and the topology they report (for example, which zone the Node is in).
- **VolumeAttachment:** a record of "which volume should be attached to which Node", created by controller-manager and handled by external-attacher.
- **StorageClass:** the `provisioner` field names the driver, and `parameters` are passed to `CreateVolume`.

---

## From PVC to Pod: one round of dynamic provisioning

Assume a StorageClass pointing at some CSI driver already exists, and a user creates a PVC and a Pod that uses it:

1. The user creates a PVC with a `storageClassName`.
2. external-provisioner sees that the PVC belongs to its driver and calls `CreateVolume`. The driver creates the actual volume and returns its ID.
3. external-provisioner creates a PV from the result, and the PV and PVC are bound (`Bound`).
4. The Pod is scheduled to a Node. If the driver needs attaching, controller-manager creates a VolumeAttachment and external-attacher calls `ControllerPublishVolume`.
5. kubelet on that Node calls `NodeStageVolume` (format, mount at the staging directory), then `NodePublishVolume` (bind mount into the Pod's directory).
6. The container starts and sees the volume at the path given in `volumeMounts`.

Deletion runs in reverse: `NodeUnpublishVolume` → `NodeUnstageVolume` → `ControllerUnpublishVolume`. After the PVC is deleted, if `reclaimPolicy` is `Delete`, `DeleteVolume` is called.

---

## The problem with local storage: which Node is the volume on?

A cloud disk can be attached to any Node in the same zone, but a local disk can't: an LV on Node A is invisible to Node B.

If the StorageClass uses the default `volumeBindingMode: Immediate`, the volume is provisioned as soon as the PVC is created, before anyone knows where the Pod will be scheduled. The volume may end up on Node A while the Pod is scheduled to Node B, and it will never mount.

The fix is `volumeBindingMode: WaitForFirstConsumer`: the PVC stays `Pending` until a Pod uses it and the scheduler picks a Node, and only then does external-provisioner call `CreateVolume` with that Node's topology. The PV then carries a `nodeAffinity`, so future Pods using this PVC are scheduled only to the same Node.

The other problem is capacity: the scheduler needs to know how much space each Node has left, or it may put a Pod on a Node whose disk is full. CSI Storage Capacity Tracking lets drivers report the free capacity of each topology segment (`CSIStorageCapacity` objects), which the scheduler takes into account when choosing a Node.

>[!NOTE] Local PVs created by hand
>Without CSI you can also create `local` PVs by hand (`spec.local.path`) with your own `nodeAffinity` naming the Node, paired with a StorageClass using `provisioner: kubernetes.io/no-provisioner` and `WaitForFirstConsumer`. This is the static-provisioning version of local storage, and it can show up on the CKA.

Next, let's see these ideas in action with TopoLVM.

---

## Hands-on: dynamic provisioning of local disks with TopoLVM

[TopoLVM](https://github.com/topolvm/topolvm) is a CSI driver backed by LVM: each PVC maps to a Logical Volume in a Volume Group on the Node. It supports dynamic provisioning, expansion and snapshots, and is topology- and capacity-aware.

The following runs in a single-node practice environment (Node name `controlplane`).

### Preparing the Volume Group

TopoLVM doesn't create the VG for you; every Node that runs TopoLVM needs one prepared in advance. The [background post](https://lcxlab.com/en/post/storage-basics-block-file-object) covers this in detail, so only the commands and output are shown here:

```bash
root@controlplane ~ ➜  pvcreate /dev/vdd
  Physical volume "/dev/vdd" successfully created.

root@controlplane ~ ➜  vgcreate topolvm-vg /dev/vdd
  Volume group "topolvm-vg" successfully created

root@controlplane ~ ➜  vgs
  VG         #PV #LV #SN Attr   VSize  VFree 
  topolvm-vg   1   0   0 wz--n- <2.00g <2.00g
```

A 2G VG with no LVs yet.

### Installing TopoLVM

TopoLVM's Helm chart uses a webhook whose certificate is issued by cert-manager by default. If the cluster doesn't have cert-manager yet, apply its CRDs first and let the chart install it:

```bash
helm repo add topolvm https://topolvm.github.io/topolvm
helm repo update

CERT_MANAGER_VERSION=v1.17.4
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.crds.yaml
```

The chart's default device class looks like this:

```yaml
lvmd:
  deviceClasses:
    - name: ssd
      volume-group: myvg1
      default: true
      spare-gb: 10
```

Two things won't work as-is: the VG name is `myvg1` while ours is `topolvm-vg`, and `spare-gb: 10` keeps 10G unallocated. Our whole VG is only 2G, so reserving 10G would leave nothing to allocate.

Also, the controller defaults to 2 replicas with a podAntiAffinity that spreads them across Nodes, so on a single Node one replica stays `Pending` forever.

Override these settings with a `values.yaml`:

```yaml
lvmd:
  deviceClasses:
    - name: ssd
      volume-group: topolvm-vg
      default: true
      spare-gb: 0

controller:
  replicaCount: 1

cert-manager:
  enabled: true
```

Install:

```bash
kubectl create namespace topolvm-system
helm install topolvm topolvm/topolvm -n topolvm-system -f values.yaml
```

>[!TIP] 💡 The control-plane taint
>By default the chart's controller, node and lvmd don't tolerate `node-role.kubernetes.io/control-plane:NoSchedule`. If your single-node environment keeps this taint, the Pods can't be scheduled. Check with `kubectl describe node controlplane | grep Taints`, and if needed add `tolerations` for them in the values.

### What got installed

```bash
kubectl get pods -n topolvm-system
```

Matching the architecture described earlier, you should see:

- **topolvm-controller** (Deployment): the driver plus csi-provisioner, csi-resizer, csi-snapshotter and liveness-probe.
- **topolvm-node** (DaemonSet): the driver plus csi-registrar (node-driver-registrar) and liveness-probe.
- **topolvm-lvmd** (DaemonSet): the daemon that actually runs `lvcreate` and `lvremove`; topolvm-node calls it over gRPC.

Use `kubectl get pod <name> -n topolvm-system -o jsonpath='{.spec.containers[*].name}'` to list the containers in each Pod. Note that the controller has no external-attacher: local LVs don't need attaching to a Node.

Check that the driver is registered:

```bash
kubectl get csidriver
kubectl get csinode controlplane -o yaml
```

`topolvm.io` appears under `spec.drivers` in the CSINode; this is the result of node-driver-registrar registering with kubelet.

You can also look at the capacity TopoLVM reports:

```bash
kubectl get node controlplane -o yaml | grep topolvm
kubectl get csistoragecapacities -A
```

### StorageClass

The chart creates a StorageClass named `topolvm-provisioner` by default:

```bash
kubectl get storageclass topolvm-provisioner -o yaml
```

It looks roughly like this:

```yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: topolvm-provisioner
provisioner: topolvm.io
parameters:
  csi.storage.k8s.io/fstype: xfs
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
reclaimPolicy: Delete
```

- `provisioner: topolvm.io`: handled by TopoLVM's external-provisioner.
- `volumeBindingMode: WaitForFirstConsumer`: local storage must wait until the Pod has a Node before creating the volume.
- With several device classes, add `topolvm.io/device-class: ssd` to `parameters` to pick the VG; without it the one with `default: true` is used.

### Creating a PVC

```yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: lvm-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: topolvm-provisioner
  resources:
    requests:
      storage: 500Mi
```

```bash
kubectl apply -f pvc.yaml
kubectl get pvc lvm-pvc
```

The PVC stays `Pending`, and the events in `kubectl describe pvc lvm-pvc` say it is waiting for the first consumer (`WaitForFirstConsumer`). That's expected; there is no LV in the VG yet.

### Creating a Pod that uses it

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: lvm-app
spec:
  containers:
    - name: app
      image: busybox
      command: ["sh", "-c", "sleep 3600"]
      volumeMounts:
        - name: data
          mountPath: /data
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: lvm-pvc
```

```bash
kubectl apply -f pod.yaml
kubectl get pvc lvm-pvc
kubectl get pv
```

Once the Pod is scheduled to `controlplane`, the PVC becomes `Bound` and a new PV appears. Look at the PV:

```bash
kubectl get pv <pv name> -o yaml
```

The key parts:

- `spec.csi.driver: topolvm.io` and `spec.csi.volumeHandle`: which driver manages the volume, and its ID on the driver side.
- `spec.nodeAffinity`: restricts use to this Node; this is topology awareness at work.

### Back on the Node

Run the LVM commands again:

```bash
root@controlplane ~ ➜  vgs
root@controlplane ~ ➜  lvs
```

`#LV` goes from 0 to 1, and `lvs` lists an LV named with a UUID, about 500M in size. This is TopoLVM running `lvcreate` through lvmd after external-provisioner called `CreateVolume`.

TopoLVM also creates a `LogicalVolume` custom resource for each LV, recording which Node it is on and which LV it maps to:

```bash
kubectl get logicalvolumes
```

Check the mounts:

```bash
lsblk
mount | grep topolvm
```

The LV appears as a device mapper device under `vdd`, mounted at `/var/lib/kubelet/pods/<pod uid>/volumes/kubernetes.io~csi/<pv name>/mount`, which is the target directory of `NodePublishVolume`.

Write some data from the Pod:

```bash
kubectl exec lvm-app -- sh -c 'echo hello > /data/hello.txt && df -h /data'
```

The capacity `df` shows is that LV's.

### Expansion

The StorageClass has `allowVolumeExpansion: true`, so just change the PVC's size:

```bash
kubectl patch pvc lvm-pvc -p '{"spec":{"resources":{"requests":{"storage":"1Gi"}}}}'
kubectl get pvc lvm-pvc
```

external-resizer calls `ControllerExpandVolume` (`lvextend`), then kubelet calls `NodeExpandVolume` to grow the file system. Afterwards both `lvs` and `df -h /data` inside the Pod show about 1G.

>[!NOTE] Grow only
>A PVC's size can only be increased, never decreased. If the StorageClass doesn't have `allowVolumeExpansion: true`, the change is rejected outright. The size also can't exceed the free space in the VG; in this 2G environment it can grow to just under 2G at most.

### Cleanup

```bash
kubectl delete pod lvm-app
kubectl delete pvc lvm-pvc
lvs
```

`reclaimPolicy` is `Delete`, so deleting the PVC deletes the PV, external-provisioner calls `DeleteVolume`, the LV disappears from `lvs`, and the space returns to the VG.

---

## Beyond TopoLVM: common CSI drivers

| Type | Driver | Notes |
| --- | --- | --- |
| Local disk | TopoLVM | Carves LVs with LVM; supports expansion and snapshots |
| Local disk | DirectPV | Developed by MinIO; formats whole local disks as XFS and hands them to PVCs, originally built to run MinIO |
| Local disk | local-path-provisioner | Developed by Rancher; uses directories on the Node as volumes, built into k3s; not CSI and doesn't enforce capacity, good for testing |
| Distributed | Rook-Ceph | Runs Ceph inside the cluster, providing RBD (block), CephFS (file) and RGW (object) |
| Distributed | Longhorn | Keeps replicas of each volume on several Nodes, so it can be remounted on another Node if one dies |
| Network file | csi-driver-nfs | Dynamically creates subdirectories on an existing NFS server; supports RWX |
| Enterprise storage | NetApp Trident | Connects to NetApp ONTAP, Azure NetApp Files and Amazon FSx for NetApp ONTAP |
| Cloud | EBS / PD / Azure Disk CSI | Each cloud's block storage |

Local disk options perform best, but the volume is tied to one Node, and if the Node dies the data goes with it. Distributed and external storage trade network hops for availability.

### NetApp Trident

Many enterprise data centers already have NetApp storage. [Trident](https://docs.netapp.com/us-en/trident/) is NetApp's official CSI driver, letting Kubernetes request space from ONTAP directly.

Trident describes the storage system to connect to as a "backend", and each kind of backend has a driver. Common ones:

| Trident driver | Protocol | Volume type |
| --- | --- | --- |
| `ontap-nas` | NFS | File, supports RWX |
| `ontap-san` | iSCSI, NVMe/TCP, FC | Block |
| `ontap-nas-economy` / `ontap-san-economy` | Same as above | Several PVs share one ONTAP volume; used when the number of PVs would exceed ONTAP's volume limit |

Setup is similar to TopoLVM, except preparing a VG becomes creating a backend:

1. Install Trident (Helm or operator).
2. Create a `TridentBackendConfig` with the ONTAP management IP, the SVM and a Secret holding the credentials.
3. Create a StorageClass with `provisioner: csi.trident.netapp.io` and `parameters.backendType` set to `ontap-nas` or `ontap-san`.
4. PVCs using this StorageClass make Trident create a volume or LUN on ONTAP.

The biggest difference from TopoLVM is that the volume lives on an external storage system that any Node able to reach ONTAP can mount. So the StorageClass can use `Immediate`, and a Pod moving to another Node doesn't leave its data behind on the old one. Snapshots, clones and backups are handled by ONTAP itself.

>[!NOTE] Nodes need the matching tools
>`ontap-nas` needs an NFS client on the Nodes (`nfs-utils` / `nfs-common`); `ontap-san` needs iSCSI or NVMe tools and multipath. The CSI driver only makes the calls; the kernel modules and tools on the Node are still yours to provide, just as TopoLVM needs `lvm2`.

---

## S3 object storage and Kubernetes

CSI ends at `NodePublishVolume`, that is, "mount something as a directory in the Pod", so it deals with block and file storage. Object storage is a network service accessed through an HTTP API, and its relationship with Kubernetes runs in two directions.

### Direction one: running an S3 service on Kubernetes

Self-hosted S3 services such as MinIO and RustFS are themselves StatefulSets that need disks: each Pod gets a few volumes through PVCs (`volumeClaimTemplates`), and erasure coding spreads the data across disks on different Nodes.

```text
Application ──S3 API──▶ MinIO / RustFS (StatefulSet, several Nodes)
                           │
                           ▼ each Pod's PVCs
                      TopoLVM / DirectPV (local disks)
```

As the background post explained, data reliability only needs handling in one layer. The S3 service already takes care of it with erasure coding, so there's no need to replicate again underneath with Longhorn or Ceph. This is exactly where local-disk CSI drivers like TopoLVM and DirectPV fit best: good performance, no redundant replication, and when a Node dies the S3 service rebuilds from the data on other Nodes.

>[!WARNING] MinIO's community edition is no longer maintained
>Since October 2025 the MinIO community edition no longer ships official binaries or images, and the repo was later put into maintenance mode and archived. For new deployments, consider RustFS (which provides a Helm chart), Rook's Ceph RGW, or the commercial MinIO AIStor or NetApp StorageGRID. See the [background post](https://lcxlab.com/en/post/storage-basics-block-file-object) for details.

### Direction two: Pods using S3

The standard approach is for the application to use an SDK directly, with Kubernetes only handing the endpoint and keys to the Pod:

```yaml
env:
  - name: S3_ENDPOINT
    value: http://rustfs.storage.svc:9000
  - name: AWS_ACCESS_KEY_ID
    valueFrom:
      secretKeyRef:
        name: s3-credentials
        key: access-key
  - name: AWS_SECRET_ACCESS_KEY
    valueFrom:
      secretKeyRef:
        name: s3-credentials
        key: secret-key
```

This path doesn't involve CSI at all.

For applications that can't be changed and only know how to read and write files, a FUSE-based CSI driver can mount a bucket as a PV, such as AWS's Mountpoint for Amazon S3 CSI Driver, or k8s-csi-s3, which works with any S3-compatible service. The limitations are the same as a FUSE mount on a host: no random writes, `rename` isn't atomic, and there are no file locks. It suits large sequential reads (such as reading datasets for AI training), not databases.

### COSI: managing buckets with Kubernetes objects

If CSI can request a volume dynamically through a PVC, can a bucket be requested the same way? That's the problem [COSI (Container Object Storage Interface)](https://github.com/kubernetes-sigs/container-object-storage-interface) sets out to solve, and conceptually it's almost a copy of CSI:

| CSI | COSI |
| --- | --- |
| StorageClass | BucketClass |
| PersistentVolumeClaim | BucketClaim |
| PersistentVolume | Bucket |
| (mounted into the Pod) | BucketAccessClass / BucketAccess: generates access keys and writes them into a Secret for the Pod |

COSI doesn't mount anything. What the Pod finally receives is a Secret containing the endpoint and keys, and the application still uses an SDK. COSI is still alpha; projects such as Rook (Ceph RGW) have implementations, but check the driver's level of support before using it in production.

---

## Troubleshooting a PVC stuck in Pending

This is the most common storage task on the CKA. Check in order:

```bash
kubectl describe pvc <name>
```

Look at the Events. Common causes:

| Symptom | Cause |
| --- | --- |
| `waiting for first consumer to be created before binding` | The StorageClass is `WaitForFirstConsumer` and no Pod uses the PVC yet; expected |
| `no persistent volumes available for this claim and no storage class is set` | Static provisioning found no matching PV: check `storageClassName`, `accessModes` and capacity |
| `storageclass.storage.k8s.io "xxx" not found` | Typo in the StorageClass name |
| `waiting for a volume to be created, either by external provisioner "xxx"` for a long time | The CSI driver's controller isn't running, or `CreateVolume` failed; check the logs of the controller's csi-provisioner container |

A Pod stuck in `ContainerCreating` means the mount stage failed: check the Events in `kubectl describe pod` and the logs of the CSI node Pod on that Node.

---

## Summary

- Pods request storage through PVCs, and PVCs bind to PVs. PVs are either created by hand by an admin (static provisioning) or generated by a StorageClass (dynamic provisioning).
- Binding depends on `storageClassName`, `accessModes` and capacity; `reclaimPolicy` decides what happens to the PV and its data after the PVC is deleted.
- CSI is a gRPC spec that replaced the old in-tree volume plugins; drivers implement three services: Identity, Controller and Node.
- Kubernetes turns PVCs and other objects into CSI calls through sidecars (external-provisioner, external-attacher, external-resizer, external-snapshotter, node-driver-registrar); on the Node, kubelet calls the driver directly.
- Local storage needs `WaitForFirstConsumer`, and the `nodeAffinity` on the PV keeps later Pods on the same Node.
- TopoLVM maps each PVC to an LV in a VG; NetApp Trident requests NFS or iSCSI / NVMe volumes from an external ONTAP system and isn't tied to a Node.
- S3 object storage doesn't go through CSI: MinIO and RustFS use PVCs themselves (best paired with a local-disk CSI driver), Pods access S3 through an SDK, and COSI creates buckets dynamically with BucketClaims.

---

## References:

[1] Kubernetes - Persistent Volumes - https://kubernetes.io/docs/concepts/storage/persistent-volumes/

[2] Kubernetes - Storage Classes - https://kubernetes.io/docs/concepts/storage/storage-classes/

[3] Kubernetes - Storage Capacity - https://kubernetes.io/docs/concepts/storage/storage-capacity/

[4] Container Storage Interface (CSI) Specification - https://github.com/container-storage-interface/spec

[5] Kubernetes CSI Developer Documentation - https://kubernetes-csi.github.io/docs/

[6] TopoLVM - https://github.com/topolvm/topolvm

[7] NetApp Trident documentation - https://docs.netapp.com/us-en/trident/

[8] KEP-1979: Object Storage Support (COSI) - https://www.kubernetes.dev/resources/keps/1979/

[9] Mountpoint for Amazon S3 CSI Driver - https://github.com/awslabs/mountpoint-s3-csi-driver
