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 but no size limit is configured — the volume can consume unlimited node memory, which is a risk in production.

The manifest file is located at:

/home/laborant/session-store.yaml

Task

Update the cache-volume definition in /home/laborant/session-store.yaml to use a memory-backed emptyDir with a size limit:

  • medium: Memory — backs the volume with RAM using tmpfs
  • sizeLimit: 256Mi — limits the volume to 256Mi

Apply the updated manifest after making the changes.


Hint 1

medium: Memory mounts the volume as tmpfs — it uses RAM instead of disk. This is faster than disk-backed storage but the data is lost when the Pod restarts. Setting sizeLimit prevents the volume from consuming more than 256Mi of node memory.

Find the cache-volume entry under spec.template.spec.volumes in the manifest. Replace emptyDir: {} with the updated configuration.

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

See the official docs: Volumes — emptyDir


Test Cases