Bitzu

KCNA ยท Storage and troubleshooting

Volumes: what problem do they solve?

emptyDir, hostPath, configMap/secret volumes, ephemeral vs persistent, volume lifecycle vs Pod lifecycle.

Key points

  • A container's own filesystem is lost when the container restarts.
  • A volume is a directory made available to the containers of a Pod.
  • Its lifetime depends on the type: emptyDir lives as long as the Pod stays on the node, configMap and secret volumes project cluster objects as read-only files, and persistent volumes outlive the Pod.

Source: https://kubernetes.io/docs/concepts/storage/volumes/

Practice questions

Single choice

What is the lifetime of an emptyDir volume?

  1. Until the namespace is deleted
  2. Until the Pod is removed from the node
  3. Until its container restarts
  4. Until the node is rebooted only
Show answer

Answer: B. Until the Pod is removed from the node

An emptyDir is created empty when the Pod is assigned to a node and removed when the Pod is removed from that node. A container crash and restart inside the same Pod does not clear it, so the 'until the container restarts' option is wrong.

Select all that apply

Which statements about configMap volumes are true?

  1. Changes made to the files inside the container are saved to the ConfigMap
  2. They create the ConfigMap automatically when it is missing
  3. They are always mounted read-only
  4. The ConfigMap must exist before the Pod can use it
  5. A subPath mount does not receive updates when the ConfigMap changes
Show answer

Answer: C. They are always mounted read-only, D. The ConfigMap must exist before the Pod can use it, E. A subPath mount does not receive updates when the ConfigMap changes

A configMap volume is always read-only and the ConfigMap must exist for the Pod to start. Files mounted through subPath do not receive later updates. Nothing written in the container flows back into the ConfigMap.

True or false

True or false: when a container in a Pod crashes and is restarted, the data in the Pod's emptyDir volume is deleted.

Show answer

Answer: False

False. The emptyDir belongs to the Pod, not to a container, so it survives container restarts. It is deleted only when the Pod is removed from the node.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More KCNA topics in this module