K8sCalc

storage

Kubernetes PVC Generator

Generate a Kubernetes PersistentVolumeClaim YAML for Longhorn, standard SSDs, or local storage. Includes optional StorageClass definition and ReadWriteMany support.

Kubernetes Persistent Storage

Storage in Kubernetes flows through three layers: StorageClass → PV → PVC → Pod.

Dynamic Provisioning Flow

Pod references PVC →
PVC requests StorageClass →
StorageClass provisions PV (calls Longhorn/cloud API) →
PV binds to PVC →
Pod mounts PVC

Access Modes Summary

ModeShortMulti-node?Use case
ReadWriteOnceRWONoMost stateful apps (DBs, queues)
ReadWriteManyRWXYesShared files, media uploads
ReadOnlyManyROXYesRead-only shared config

Longhorn RWX Setup

Longhorn RWX uses NFSv4 under the hood. Enable with: ```yaml accessModes:

  • ReadWriteMany

storageClassName: longhorn ```

Longhorn automatically creates an NFSv4 server pod backed by a Longhorn volume.

Pod Volume Mount

yaml
spec:
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: my-app-data
  containers:
    - name: app
      volumeMounts:
        - mountPath: /data
          name: data

Frequently Asked Questions

What's the difference between PVC, PV, and StorageClass?

StorageClass defines how storage is provisioned (which plugin, which parameters). PVC is a request for storage from a pod ('I need 10Gi'). PV is the actual storage resource — either pre-provisioned manually or dynamically provisioned by the StorageClass when a PVC is created. With dynamic provisioning (Longhorn, cloud storage), you only need the StorageClass and PVC.

Can I resize a PVC?

If the StorageClass has allowVolumeExpansion: true, you can resize by editing the PVC's storage request to a larger value. For Longhorn: it supports online expansion — the volume grows while pods are running. For most cloud block storage (EBS, GCP PD), you need to restart the pod after resize. You cannot shrink a PVC.

What's ReadWriteMany (RWX) and when do I need it?

RWX allows multiple pods on different nodes to mount the same volume simultaneously. Use it for shared config files, media uploads, or stateless apps with shared state. Longhorn supports RWX via an NFSv4 backing service. Most cloud block storage (EBS, GCP PD) only supports RWO. For RWX at scale, consider an object store (MinIO, S3) instead.

What happens if I delete a PVC?

It depends on the StorageClass's reclaimPolicy. Retain: PV is kept, data is safe, but the PVC is gone — you must manually rebind. Delete: both PV and underlying storage are destroyed — data is gone. Longhorn defaults to Delete. Always snapshot important data before deleting PVCs in production.

Related Calculators