12 Kubernetes Storage Options Explained

12 Kubernetes storage options explained: emptyDir, hostPath, local PVs, PVCs, StorageClasses, CSI block and file storage, Rook/Ceph and object storage.

Dec 9, 2025 - 17:18
Nov 10, 2026 - 03:12
 0  257
12 Kubernetes Storage Options Explained

Kubernetes storage options fall into three groups: ephemeral volumes that live and die with a Pod (emptyDir, configMap, Secret, generic ephemeral volumes), node-bound storage (hostPath, local PersistentVolumes), and persistent storage requested through PersistentVolumeClaims and StorageClasses, usually backed by a CSI driver for block, file or software-defined storage. This guide explains 12 options and when each one fits.

Storage sits on top of the control plane and kubelet parts described in our Kubernetes architecture components guide. If you are new to the scheduler, kubelet and etcd, read that first. Everything below was checked against the kubernetes.io storage documentation in November 2026.

Key takeaways

  • Anything a container writes to its own filesystem is lost when the container restarts. Use a volume for any data you need to keep.
  • emptyDir and generic ephemeral volumes are scratch space. They are deleted with the Pod.
  • For real persistence, an application asks for storage with a PersistentVolumeClaim (PVC). A StorageClass tells Kubernetes how to create the matching PersistentVolume (PV).
  • Cloud disks are now attached through CSI drivers. The old in-tree plugins such as awsElasticBlockStore and azureDisk have been removed from Kubernetes.
  • Pick block storage (ReadWriteOnce) for databases and file storage (ReadWriteMany) when several Pods must share the same files.
  • Avoid hostPath for applications. It ties the Pod to one node and opens a security hole.

The vocabulary you need first

Object or termWhat it isWho usually creates it
VolumeA directory mounted into a container, declared in the Pod specDeveloper
PersistentVolume (PV)A piece of storage in the cluster with its own lifecycle, independent of any PodAdmin (static) or a provisioner (dynamic)
PersistentVolumeClaim (PVC)A request for storage: size, access mode and optionally a StorageClassDeveloper
StorageClassA template naming a provisioner and its parameters, such as disk typeAdmin
CSI driverA plugin that implements the Container Storage Interface so Kubernetes can create, attach and mount a vendor's storageStorage vendor, installed by the admin
Access modeReadWriteOnce, ReadOnlyMany, ReadWriteMany or ReadWriteOncePodSet on the PVC

One detail trips up many beginners: ReadWriteOnce means one node, not one Pod. Several Pods on the same node can still mount the volume. If you need exactly one Pod, use ReadWriteOncePod, which became stable in Kubernetes 1.29 and works only with CSI volumes.

Comparison of the 12 storage options

#OptionSurvives Pod deletion?Shared across nodes?Typical use
1emptyDirNoNoScratch space, caches, sidecar hand-off
2configMap, Secret, downwardAPI, projectedData lives in the API, not the volumeYes (via the API)Config files and credentials
3Generic ephemeral volumeNoDepends on driverLarge scratch space from a StorageClass
4CSI ephemeral inline volumeNoDepends on driverSecrets or certs injected by a CSI driver
5hostPathYes, on that nodeNoNode agents only (log collectors, CNI)
6Local PersistentVolumeYes, on that nodeNoFast NVMe for replicated databases
7Static PV and PVCYesDepends on backendExisting disks or NFS exports
8Dynamic provisioning with StorageClassYesDepends on backendThe default for most stateful apps
9Cloud block storage via CSIYesNo (one node at a time)Databases, queues
10Shared file storage (NFS and cloud file services)YesYesShared uploads, CMS content, ML datasets
11Software-defined storage (Rook/Ceph, Longhorn)YesYes (replicated)On-premises and bare-metal clusters
12Object storageYesYesBackups, media, data lakes

Ephemeral options

1. emptyDir

An emptyDir volume is created empty when the Pod is assigned to a node and deleted when the Pod is removed. It survives container restarts inside the Pod, which makes it useful for caches and for passing files between an init container, the main container and a sidecar. Setting medium: Memory backs it with tmpfs, and the memory used counts against the container's memory limit. Always set sizeLimit so one Pod cannot fill the node's disk.

volumes:
- name: cache
  emptyDir:
    sizeLimit: 500Mi

2. configMap, Secret, downwardAPI and projected volumes

These volumes expose data stored in the Kubernetes API as files. A configMap volume mounts configuration files, a Secret volume mounts credentials (on tmpfs, so they are not written to the node's disk), and downwardAPI exposes Pod metadata such as labels. A projected volume combines several of these sources, plus service account tokens, into one directory. Files mounted this way are updated when the source object changes, except when mounted with subPath. For safer handling of credentials, see our guide to tools that manage Kubernetes Secrets.

3. Generic ephemeral volumes

A generic ephemeral volume gives a Pod scratch space from any StorageClass that supports dynamic provisioning. Kubernetes creates a PVC owned by the Pod and deletes it when the Pod goes away. Use it when emptyDir is too small or too slow, for example a build job that needs 200 GiB of fast SSD for one run. The feature has been stable since Kubernetes 1.23.

volumes:
- name: scratch
  ephemeral:
    volumeClaimTemplate:
      spec:
        accessModes: [ "ReadWriteOnce" ]
        storageClassName: fast-ssd
        resources:
          requests:
            storage: 200Gi

4. CSI ephemeral inline volumes

Some CSI drivers can create a volume declared directly in the Pod spec, with no PVC. The best-known example is the Secrets Store CSI Driver, which mounts secrets from Vault, AWS Secrets Manager, Azure Key Vault or Google Secret Manager as files. Only drivers that declare support for the Ephemeral lifecycle mode can be used this way, so check the driver's documentation.

Node-bound options

5. hostPath

hostPath mounts a file or directory from the node into the Pod. The Kubernetes documentation warns that it carries many security risks and recommends avoiding it where possible. A Pod with write access to the host filesystem can read other workloads' data or tamper with the kubelet. Legitimate uses are node-level agents, such as a log collector reading /var/log/pods. If you must use it, mount read-only, scope it to the exact directory, and restrict it with Pod Security Admission (the Baseline profile disallows hostPath).

6. Local PersistentVolumes

A local PV represents a disk attached to a specific node, such as an NVMe drive. Unlike hostPath, the scheduler knows about it: the PV carries nodeAffinity, so Pods using it always land on the right node. Create its StorageClass with volumeBindingMode: WaitForFirstConsumer so binding waits until the Pod is scheduled. The trade-off is availability. If the node dies, the data is unavailable until it returns, so local PVs suit databases that replicate data themselves, such as Cassandra or a MongoDB replica set.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-nvme
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

Persistent options

7. Static PersistentVolumes and claims

With static provisioning, an administrator creates PVs by hand, pointing at existing storage such as an NFS export or a pre-created disk. Developers then claim them with PVCs, and Kubernetes binds each claim to a PV that meets its size and access mode. This is common when migrating an existing application with data already on a known disk. The persistentVolumeReclaimPolicy decides what happens after the claim is deleted: Retain keeps the data for manual cleanup, Delete removes the backing storage. The older Recycle policy is deprecated.

8. Dynamic provisioning with StorageClasses

Dynamic provisioning is how most clusters work today. The admin defines one or more StorageClasses, each naming a CSI provisioner and parameters. When a PVC references a class, the provisioner creates the disk and the PV automatically. One class can be marked default with the storageclass.kubernetes.io/is-default-class: "true" annotation, and PVCs without a class name get it.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: gp3
provisioner: ebs.csi.aws.com
parameters:
  type: gp3
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
reclaimPolicy: Delete
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-data
spec:
  accessModes: [ "ReadWriteOnce" ]
  storageClassName: gp3
  resources:
    requests:
      storage: 50Gi

Setting allowVolumeExpansion: true lets you grow a volume later by editing the PVC's storage request. Volumes can be expanded, not shrunk. For StatefulSets, use volumeClaimTemplates so each replica gets its own PVC; our post on StatefulSets vs Deployments explains why.

9. Cloud block storage through CSI

Each cloud provider ships a CSI driver for its block disks: the Amazon EBS CSI driver (ebs.csi.aws.com), the Azure Disk CSI driver (disk.csi.azure.com) and the Compute Engine Persistent Disk CSI driver (pd.csi.storage.gke.io). Block disks attach to one node at a time and are zonal, so a Pod cannot follow its disk into another availability zone. That is the main reason to use WaitForFirstConsumer: the disk is created in the zone where the Pod is scheduled.

The older in-tree plugins have gone. Kubernetes migrated them to CSI and then removed them; awsElasticBlockStore and azureDisk were removed in 1.27 and gcePersistentDisk in 1.28. Manifests that still use those volume types need the CSI driver and a CSI-based StorageClass.

A PVC can also set volumeMode: Block to hand the raw device to the container without a filesystem, which some databases prefer.

10. Shared file storage

When several Pods on different nodes must read and write the same files, you need ReadWriteMany, which block disks cannot give you. Options include a plain NFS server (Kubernetes has a built-in nfs volume type, and the NFS CSI driver adds dynamic provisioning), Amazon EFS through the EFS CSI driver, Azure Files through its CSI driver, and Google Cloud Filestore. File storage has higher latency than local block storage, so it suits shared content rather than database data files.

11. Software-defined storage: Rook/Ceph and Longhorn

On bare metal or on-premises clusters there is no cloud disk to call. Software-defined storage pools the disks on your nodes and replicates data between them. Rook is a CNCF graduated project that runs Ceph inside Kubernetes, offering block (RBD), shared file (CephFS) and S3-compatible object storage from one cluster. Longhorn, a CNCF project started by Rancher, gives replicated block storage with a simpler setup and built-in snapshots and backups to S3 or NFS. Both need care: plan disk, network and node capacity for replication, and test what happens when a node fails.

12. Object storage

Object storage such as Amazon S3, Azure Blob Storage, Google Cloud Storage or a self-hosted S3-compatible service is not a filesystem. Applications usually talk to it through an SDK and the HTTP API, and Kubernetes only provides the credentials. Some CSI drivers, such as Mountpoint for Amazon S3, can mount a bucket as files, but they do not support every POSIX operation, so read the driver's limits before pointing a database at one. Object storage is the natural home for backups, media and log archives.

Snapshots, backups and recovery

CSI drivers that support it let you take a point-in-time copy of a PVC with the VolumeSnapshot API, stable since Kubernetes 1.20. You restore by creating a new PVC with the snapshot as its dataSource. Snapshots usually live in the same provider and region, so they are not a full backup plan. Tools such as Velero copy both Kubernetes objects and volume data elsewhere. Our guides to Kubernetes backup tools and disaster recovery tools compare the options.

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: postgres-data-snap
spec:
  volumeSnapshotClassName: csi-snapclass
  source:
    persistentVolumeClaimName: postgres-data

How to choose: a short decision guide

Your workloadStart withWhy
Stateless web app needing temp filesemptyDir with sizeLimitCheap, no cleanup
Single-instance database on a cloudPVC on a block StorageClass, RWOLow latency, snapshots, expansion
Replicated database needing top IOPSLocal PVsFastest disks; the database handles replication
Many Pods sharing uploaded filesRWX file storage (EFS, Azure Files, NFS)Multi-node read and write
Bare-metal clusterRook/Ceph or LonghornNo cloud disks available
Backups, media, archivesObject storage via SDKCheap, durable, scalable
Config and credentialsconfigMap and Secret volumes, or a CSI secrets driverManaged through the API

Common mistakes and how to avoid them

  • Pods stuck in Pending with a PVC. Run kubectl describe pvc NAME. Common causes are no default StorageClass, a CSI driver that is not installed, or an access mode the backend does not support.
  • Volume node affinity conflict. A zonal disk was created in one zone and the Pod was scheduled in another. Use WaitForFirstConsumer.
  • Data lost after deleting a namespace. The reclaim policy was Delete. For important data, use Retain or take snapshots and backups.
  • Permission denied on mount. The container runs as a non-root user that cannot write to the volume. Set fsGroup in the Pod securityContext.
  • Running out of disk space. Monitor the kubelet volume stats metrics with Prometheus and alert before a PVC is full.

Useful commands while debugging:

kubectl get storageclass
kubectl get pv,pvc -A
kubectl describe pvc postgres-data
kubectl get csidrivers
kubectl get volumesnapshot -n NAMESPACE

Learn Kubernetes storage hands-on

Storage is part of the "Storage" domain in the Certified Kubernetes Administrator exam: StorageClasses, PVs, PVCs, access modes and reclaim policies. Our CKA training covers these with lab work, in the classroom in Kharadi, Pune or live online. To see how storage fits rollouts, read our Kubernetes deployment strategies guide.

Frequently asked questions

What is the difference between a PV and a PVC?

A PersistentVolume is the actual storage in the cluster. A PersistentVolumeClaim is a request for storage made by an application. Kubernetes binds a claim to a volume that matches its size, access mode and StorageClass, and the Pod mounts the claim.

Is emptyDir persistent?

No. An emptyDir survives container restarts inside the same Pod, but it is deleted when the Pod is removed or moved to another node. Use a PVC for data you need to keep.

What does ReadWriteOnce actually mean?

ReadWriteOnce means the volume can be mounted read-write by a single node. Multiple Pods on that node can still use it. ReadWriteOncePod restricts it to a single Pod and requires a CSI driver.

Why should I use WaitForFirstConsumer?

It delays creating and binding the volume until a Pod using the claim is scheduled. The disk is then created in the zone where the Pod runs, which avoids volume node affinity conflicts with zonal block storage and local volumes.

Can I still use awsElasticBlockStore volumes?

No. The in-tree awsElasticBlockStore and azureDisk plugins were removed in Kubernetes 1.27 and gcePersistentDisk in 1.28. Install the cloud provider's CSI driver and use a StorageClass that names it.

Which storage should I use for a database on Kubernetes?

Use a StatefulSet with volumeClaimTemplates on a block StorageClass with ReadWriteOnce. If the database replicates data itself and needs maximum performance, local PersistentVolumes are an option. Add snapshots and off-cluster backups either way.

Can I shrink a PersistentVolumeClaim?

No. Kubernetes supports expanding a PVC when the StorageClass allows it, but not shrinking. To reduce size, create a smaller volume and copy the data across.

Is hostPath safe to use?

Only for trusted node agents, and preferably read-only. The Kubernetes documentation warns that hostPath exposes the node to many security risks, and the Pod Security Baseline profile blocks it for ordinary workloads.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.