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
What is the lifetime of an emptyDir volume?
- Until the namespace is deleted
- Until the Pod is removed from the node
- Until its container restarts
- 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.
Which statements about configMap volumes are true?
- Changes made to the files inside the container are saved to the ConfigMap
- They create the ConfigMap automatically when it is missing
- They are always mounted read-only
- The ConfigMap must exist before the Pod can use it
- 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: 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.
