- Docker containers are meant to be transients in nature which means they are meant to last only for a short period of time. They are called upon when required to process data and destroyed once finished.
- The same is true for the data within the container. The data is destroyed along with the container.
- To persist data processed by the containers, we attach a persistent volume to the containers when they are created.
- OpenShift leverages the Kubernetes persistent volume framework to provision storage for a cluster.
- Storage can be provisioned to an OpenShift cluster using any of the plugins listed such as local, iSCSI, Fiber Channel, NFS, or from a variety of supported platforms such as GlusterFS, Ceph RDB, OpenStacks Cinder, AWS Elastic Blocks Strore, Azure Disk, Azure File, or VMWare vSphere.
- The Storage added to the OpenShift cluster is available across the cluster as a single large pool of persistent volume resources.
- Each project can claim the required amount of storage using persistent volume claims.
- This storage can then be used as persistent storage within the pods in each projects.
- To create storage, click Create Storage in the web console.
- Select Access Mode:
- Single User (RWO) allows the volume to be mounted as read/write by a single node only.
- Shared Access (RWX) allows volume to be mounted by multiple nodes for read/write access
- Read Only (ROX) allows volume to be mounted by multiple nodes but read only
- The created storage can be attached to pods by adding to the deployment configuration
- For your simple-webapp-color application, try to access at URI
/read_fileand you will get Internal Server Error.
- Create a storage pool.
- Add storage to the deployment configuration simple-webapp-color
- You should now see the the mounted
/dataon the pods
- Try to create the file with command
echo "This is the test data" > /data/testfile.txt
- And you should see: