Lifecycle of Volumes
The lifecycle of volumes mounted inside a pod is tied to the pod itself - not to the containers they are mounted into. Volumes are created when the pod is set up, before any of its containers are created, and are torn down when the pod is shut down. Depending on the volume type, the files in the volume can remain intact even after the pod and the volume vanish, and can later be mounted into a new volume.
Available Volume Types
- emptyDir - A simple directory that enables the pod to store data for the duration of its life cycle. The files are stored in a directory in the host node’s file system, or in the host node’s memory for sensitive data. The directory is then mounted into the container at the specified location, as a volume. An
emptyDirvolume is a dedicated directory created specifically for, and used exclusively by, the pod in which the volume is defined. When the pod is deleted, the volume and its contents are deleted. You can use other types of volumes to mount an existing external directory into the containers.