Challenge, Easy,  on  Kubernetes

Configure a Memory-Backed emptyDir Volume with a Size Limit

Scenario

A Deployment named session-store is running in namespace cherry. The Pods use a volume named cache-volume of type emptyDir — currently disk-backed with no size limit.

The application needs faster I/O, so the team wants to switch the volume to memory-backed storage using tmpfs. However, a memory-backed emptyDir without a size limit can consume all available node RAM and trigger the OOM killer.

The manifest is on the dev-machine at:

/home/laborant/session-store.yaml

Task

Update cache-volume in the manifest to use memory-backed storage with a size limit:

  • medium: Memory
  • sizeLimit: 256Mi

Apply the updated manifest.


Hint

medium: Memory mounts the volume as tmpfs — it uses RAM instead of disk.Reads and writes are significantly faster than disk-backed storage, but the data is lost when the Pod restarts. Without sizeLimit, the volume can grow until the node runs out of memory — so always cap it.

Then apply:

kubectl apply -f /home/laborant/session-store.yaml

See the official docs: Volumes — emptyDir


Test Cases