Overview
Introduction
Every Pod that needs durable storage does so through a PersistentVolumeClaim, a namespaced request for a chunk of storage with a given size and access mode, but the exact YAML shape (nested resources.requests.storage, optional selector.matchLabels) is easy to get slightly wrong from memory.
This tool builds a valid PVC manifest from a small form: access modes, a storage size, an optional storage class, and optional selector labels.
What Is Kubernetes PersistentVolumeClaim Generator?
A form-based generator for the `v1/PersistentVolumeClaim` resource, the namespaced object a Pod's volume references in order to get durable storage.
It covers the fields you'll set on almost every PVC: one or more access modes, a storage size request, an optional storageClassName (to target dynamic provisioning or a specific class), and an optional label selector for binding to a specific pre-existing PersistentVolume.
How Kubernetes PersistentVolumeClaim Generator Works
Your selected access modes become the `accessModes` list, your storage size becomes `resources.requests.storage` (validated as a real Kubernetes quantity), and storageClassName, when set, is added verbatim.
If you add one or more selector labels, the tool emits a `selector.matchLabels` block so the claim only binds to PersistentVolumes carrying those exact labels; if you leave it empty, no selector is emitted and any PV or dynamic provisioner satisfying the other fields is eligible.
When To Use Kubernetes PersistentVolumeClaim Generator
Use it any time a Pod, Deployment, or StatefulSet needs a chunk of durable storage and you need the claim manifest to request it.
It's especially useful when binding to a specific, hand-provisioned PersistentVolume via a selector, since that field's exact nesting is one of the easier PVC details to forget.
Often used alongside Kubernetes PersistentVolume Generator and Kubernetes StatefulSet Generator.
Features
Advantages
- Validates the storage size as a real Kubernetes quantity before generating output, catching malformed sizes early.
- Supports the optional selector block without cluttering the output when you don't need one.
- Covers all three standard access modes so you don't need to look up their exact capitalization each time.
Limitations
- Doesn't generate a `dataSource`/`dataSourceRef` block for cloning from a snapshot or another PVC; those are less common, more provisioner-specific fields.
- Doesn't validate that your requested size or access mode will actually find a matching PersistentVolume or provisioner in a real cluster, only that the YAML itself is well-formed.
Examples
Best Practices & Notes
Best Practices
- Set storageClassName explicitly rather than relying on the cluster default, so the manifest behaves the same regardless of which cluster it's applied to.
- Match accessModes to what your workload actually needs: ReadWriteOnce for a single Pod's exclusive volume, ReadWriteMany only when multiple Pods genuinely need concurrent write access (and your storage backend supports it).
- Use a selector only when you have a specific pre-provisioned PV you need to bind to; for dynamic provisioning, leave it off and let the storage class handle it.
Developer Notes
Storage size validation reuses the same Kubernetes binary-suffix quantity regex (Ki/Mi/Gi/Ti/Pi/Ei) as the PersistentVolume Generator, since PVC and PV `resources`/`capacity` quantities share the same format. The selector, when present, is always rendered as `matchLabels` rather than `matchExpressions`, covering the overwhelmingly common case of simple key/value label matching.
Kubernetes PersistentVolumeClaim Generator Use Cases
- Requesting durable storage for a Deployment's data directory via a volume mount
- Binding to a specific, hand-provisioned PersistentVolume using a label selector
- Producing a PVC manifest to pair with the PersistentVolume Generator's output during local cluster setup
Common Mistakes
- Requesting an access mode the underlying storage backend doesn't actually support (e.g. ReadWriteMany on a backend that only supports ReadWriteOnce), which leaves the claim stuck Pending.
- Forgetting storageClassName and getting a PVC bound via the cluster's default class instead of the one intended.
- Adding a selector that doesn't match any existing PV's labels, which leaves the claim unbound indefinitely.
Tips
- Generate the PersistentVolume first with the PersistentVolume Generator, then set matching storageClassName and accessModes here so the two bind cleanly.