In this section, we will take a look at Volumes
The data are processed by the container is now placed in this volume thereby retaining it permanently. Even if the container is deleted the data remains in the volume.
/opt/number.out
. To persist into the volume./data
on the host. Files are stored in the directory data on my node. We use the volumeMounts field in each container to mount the data-volume to the directory /opt
within the container. The random number will now be written to /opt
mount inside the container, which happens to be on the data-volume which is in fact /data
directory on the host. When the pod gets deleted, the file with the random number still lives on the host.volumes:
- name: data-volume
awsElasticBlockStore:
volumeID: <volume-id>
fsType: ext4