When a pod is stopped or when it crashes, all the data related to it is lost.
For the data to persist beyond the lifecycle of a pod, we write it to a volume - directory on the host mounted inside the pod -.
We can configure the pod to use a directory on the host as its own storage.
Below the Yaml configuration file of a pod with its attached volume:
To have access to the directory on the node, the directory is mounted on a mountpoint - directory - inside the container.
We can create our pod using the below command:
If the pod is deleted the data persists on the host. This solution works better in a single node scenario.
Different types of storage:
We have different type of storage types like NFS, cephfs, ...
Below we use AWS for our storage: