Ephemeral Storage Management Guide
Manage ephemeral storage in Kubernetes with emptyDir size limits, ephemeral-storage requests and limits, and eviction thresholds.
π‘ Quick Answer: Set
resources.limits.ephemeral-storage: 2Gion containers to prevent runaway log/temp file growth. UseemptyDir.sizeLimit: 1Gifor temporary volumes. Monitor node disk usage β kubelet evicts pods when ephemeral storage exceeds limits or node hits disk pressure.
The Problem
Containers write logs, temp files, and cached data to ephemeral storage (the nodeβs filesystem). Without limits, a single pod writing unlimited logs can fill the node disk, triggering DiskPressure and evicting ALL pods on that node β including healthy ones.
The Solution
Ephemeral Storage Limits
apiVersion: v1
kind: Pod
metadata:
name: app
spec:
containers:
- name: app
image: registry.example.com/app:1.0
resources:
requests:
ephemeral-storage: 500Mi
limits:
ephemeral-storage: 2Gi
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir:
sizeLimit: 1GiWhat Counts as Ephemeral Storage
| Source | Counted? |
|---|---|
| Container writable layer | β Yes |
| Container logs (/var/log/pods) | β Yes |
| emptyDir volumes | β Yes |
emptyDir with medium: Memory | β No (uses RAM) |
| PersistentVolume mounts | β No |
LimitRange for Namespace Defaults
apiVersion: v1
kind: LimitRange
metadata:
name: ephemeral-defaults
namespace: production
spec:
limits:
- type: Container
defaultRequest:
ephemeral-storage: 256Mi
default:
ephemeral-storage: 1Gigraph TD
WRITE[Container writes<br/>logs + temp files] -->|Exceeds limit| EVICT[Pod evicted<br/>ephemeral-storage exceeded]
WRITE -->|Node disk > 85%| PRESSURE[DiskPressure<br/>ALL pods at risk]
LIMIT[ephemeral-storage: 2Gi] -->|Prevents| WRITE
EMPTYDIR[emptyDir sizeLimit: 1Gi] -->|Caps /tmp| WRITECommon Issues
Pod evicted with βephemeral-storage exceededβ
Container + logs + emptyDir exceeded the limit. Check whatβs writing: kubectl exec pod -- du -sh /tmp /var/log.
Node in DiskPressure β all pods being evicted
A pod without ephemeral limits filled the disk. Set limits on all pods and configure kubelet eviction thresholds: --eviction-hard=nodefs.available<15%.
Best Practices
- Set ephemeral-storage limits on ALL containers β one unbounded pod can take down a node
- emptyDir sizeLimit for temp volumes β prevents cache/scratch from growing unbounded
- LimitRange for namespace defaults β catches pods without explicit limits
- Log rotation in application β donβt rely solely on K8s limits
- Monitor
kubelet_volume_stats_used_bytesβ alert before DiskPressure
Key Takeaways
- Ephemeral storage includes container writes, logs, and emptyDir volumes
- Pods exceeding ephemeral-storage limits are evicted β not OOMKilled, evicted
- Without limits, one podβs logs can trigger DiskPressure and evict all pods on the node
- LimitRange provides namespace-wide defaults for pods without explicit limits
- emptyDir
sizeLimitis separate from container ephemeral-storage limits

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
