Persistent storage can be used for database storage, or storage of stateful information that needs to be referenced by multiple application instances. For sensitive information like passwords or tokens, please use either Secrets or Environmental Variables, also referenced in this section.
The OpenShift documentation for claiming and utilizing persistent storage is here.
Using A Claim Within A Project
After making the claim using the yaml specified above, open the deployment config for the app that will be using the storage. Click on ‘Attach storage’ in the lower left-hand corner:
In the resulting form, specify the mount point for the claim within your apps.
Note:If you are modifying a multi-pod deployment config, all pods will mount the claim at the same place, unless otherwise specified. After you click ‘Attach’, your pods will be automatically redeployed with the storage attached.
The deployment config will now look like this:
Adding Files To Storage
OpenShift relies on rsync to get files to persistent storage. Use the oc rsync command to send files to the newly mounted volume as follows ‘/usr/share/ocellus’ is the mount point for a pod called ‘rsync-client-2-sn42m’:
$ oc rsync . rsync-client-2-sn42m:/usr/share/ocellus
building file list ... done
sent 4914 bytes received 48 bytes 3308.00 bytes/sec
total size is 4797 speedup is 0.97
rsync: chown "/usr/share/ocellus/." failed: Operation not permitted (1)
rsync: chown "/usr/share/ocellus/.settings.py.FCAWD0" failed: Operation not permitted (1)
rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/main.c(992) [sender=2.6.9]
error: exit status 23
Connecting To A Multi-Container Pod
Some pods will have multiple containers, such as having apache and tomcat instances as part of the same pod. In this case, you must specify the container which that files will be moved to or from. Here is an example:
oc rsync -c 'apache' mypod-1-53r40:/usr/local/apache2/local/certs .
Note: In this example the user is rsyncing files from the 'apache' container of a pod called 'mypod'. Similar syntax works for rsh'ing to that container.