Generic ephemeral volumes

Generic Ephemeral Volumes in Kubernetes are a feature that allows you to provision ephemeral (temporary), per-pod volumes using existing StorageClasses and CSI drivers, without needing to predefine PersistentVolumeClaims (PVCs).

They combine the flexibility of dynamic provisioning with the simplicity of pod-level volume declaration.

  • They are temporary volumes that are automatically:

    • created when the Pod starts

    • deleted when the Pod terminates

  • Use the same underlying mechanisms as PersistentVolumeClaim

  • Require a CSI (Container Storage Interface) driver that supports dynamic provisioning

Example ephemeral volumes

This automatically creates a temporary PVC for the Pod using the specified StorageClass.

apiVersion: v1
kind: Pod
metadata:
  name: ephemeral-demo
spec:
  containers:
    - name: app
      image: busybox
      command: ["sh", "-c", "echo hello > /data/hello.txt && sleep 3600"]
      volumeMounts:
        - mountPath: /data
          name: ephemeral-volume
  volumes:
    - name: ephemeral-volume
      ephemeral:
        volumeClaimTemplate:
          metadata:
            labels:
              type: temporary
          spec:
            accessModes: [ "ReadWriteOnce" ]
            resources:
              requests:
                storage: 1Gi
            storageClassName: standard
  1. Pod will create a PVC by using this template.

Key features

FeatureDescription
EphemeralVolume is deleted when the Pod is deleted
Dynamic provisioningBacked by any CSI driver with dynamic provisioning
No separate PVCVolumeClaim is embedded directly in the Pod spec
CSI-poweredWorks with any compatible CSI driver (EBS, RBD, Longhorn, etc.)

When to Use Generic Ephemeral Volumes

  • When you need temporary storage with features like:

    • Resizable volumes

    • Snapshots

    • Encryption

    • Non-node-local storage (e.g., cloud block storage)

  • Ideal for:

    • Caching intermediate data

    • Temporary working directories

    • Pipelines, AI/ML workflows

How Are They Different from emptyDir?

FeatureemptyDirGeneric Ephemeral Volume
Backing storageNode's local disk or memoryAny CSI-supported backend
Storage featuresBasicSupports snapshots, encryption, etc.
Use caseSimple temporary storageAdvanced ephemeral storage needs
ReschedulableNo (tied to node)Yes (if CSI volume is attachable)