πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Storage beginner ⏱ 15 minutes K8s 1.28+

Kubernetes Volume Types Explained

Compare all Kubernetes volume types: emptyDir, hostPath, PVC, ConfigMap, Secret, NFS, CSI, and projected volumes. When to use each type with examples.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: Compare all Kubernetes volume types: emptyDir, hostPath, PVC, ConfigMap, Secret, NFS, CSI, and projected volumes. When to use each type with examples.

The Problem

This is one of the most searched Kubernetes topics. A comprehensive, well-structured guide helps engineers of all levels quickly find actionable solutions.

The Solution

Detailed implementation with production-ready examples below.

Volume Types Comparison

TypePersistenceAccessUse Case
emptyDirPod lifetimeSingle podCache, temp files
hostPathNode lifetimeSingle nodeNode-level data (dev only!)
persistentVolumeClaimIndependentConfigurableDatabases, stateful apps
configMapConfigMap lifetimeRead-onlyConfig files
secretSecret lifetimeRead-onlyCredentials, TLS certs
nfsNFS serverReadWriteManyShared file storage
csiDriver-dependentDriver-dependentCloud/enterprise storage
projectedSource lifetimeRead-onlyCombine multiple sources
downwardAPIPod lifetimeRead-onlyPod metadata as files

Examples

volumes:
  # emptyDir β€” temp storage
  - name: cache
    emptyDir:
      sizeLimit: 1Gi

  # hostPath β€” node filesystem (DANGEROUS in production)
  - name: docker-sock
    hostPath:
      path: /var/run/docker.sock
      type: Socket

  # PVC β€” persistent storage
  - name: data
    persistentVolumeClaim:
      claimName: my-data

  # ConfigMap as files
  - name: config
    configMap:
      name: app-config
      items:
        - key: nginx.conf
          path: nginx.conf

  # Secret as files
  - name: certs
    secret:
      secretName: tls-certs

  # Projected β€” combine multiple sources
  - name: combined
    projected:
      sources:
        - configMap:
            name: app-config
        - secret:
            name: app-secrets
        - downwardAPI:
            items:
              - path: labels
                fieldRef:
                  fieldPath: metadata.labels
graph TD
    A{Need persistence?} -->|No - temp/cache| B[emptyDir]
    A -->|Yes| C{Shared across pods?}
    C -->|No - single pod| D[PVC with RWO]
    C -->|Yes - multiple pods| E[PVC with RWX - NFS/CephFS]
    F{Config or secrets?} -->|Config files| G[configMap volume]
    F -->|Credentials| H[secret volume]
    F -->|Both + metadata| I[projected volume]

Common Issues

Check kubectl describe and kubectl get events first β€” most issues have clear error messages pointing to the root cause.

Best Practices

  • Follow least privilege β€” only grant the access that’s needed
  • Test in staging before applying to production
  • Monitor and alert on key metrics
  • Document your runbooks for the team

Key Takeaways

  • Essential knowledge for Kubernetes operations
  • Start simple and evolve your approach
  • Automation reduces human error
  • Share knowledge with your team
#volumes #emptydir #hostpath #pvc #nfs #csi #kubernetes
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens