Difficulty: beginner
Estimated Time: 5 minutes

Make your first steps with the three persistent storage options in Openshift.

Content

In this scenario, we will discover three different persistent storage options:

  • RWO storage - suited for low-latency, high-performance applications like databases
  • RWX storage - suited for distributed applications that need a common place to store data
  • OBC storage - used to get application specific access credentials for object storage buckets

Thank you for trying this scenario. To learn more about Openshift Container Storage (OCS), head over to the OCS homepage

If you want to stay up to date in regards to OCS, also check out the Red Hat Storage blog

Making Persistent Storage Calls in Your Application

Step 1 of 3

Using RWO storage

RWO storage is the most basic type of storage that is supported by most dynamic storage provisioners in the Kuberneted eco system.

With Openshift Container Storage (OCS), each RWO storage device is backed by its own block device, which means that it is well suited for high-IOPs and low-latency operations that are common for database workloads.

In this section the ocs-storagecluster-ceph-rbd storage class will be used by an Openshift application + database deployment to create RWO (ReadWriteOnce) persistent storage. The persistent storage will be a Ceph RBD (RADOS Block Device) volume (object) in the Ceph pool ocs-storagecluster-cephblockpool.

To do so we have created a template file, based on the OpenShift rails-pgsql-persistent template, that includes an extra parameter STORAGE_CLASS that enables the end user to specify the storage class the PVC (Persistent Volume Claim) should use.

oc new-project my-database-app
oc new-app rwo_rails_app.yaml -p STORAGE_CLASS=ocs-storagecluster-ceph-rbd -p VOLUME_CAPACITY=5Gi

After the deployment is started you can monitor with these commands.

oc status

Check the PVC that were created.

oc get pvc -n my-database-app

This step could take a few minutes. Wait until there are 2 Pods in Running STATUS and 4 Pods in Completed STATUS as shown below.

watch oc get pods -n my-database-app


Example output:

NAME                                READY   STATUS      RESTARTS   AGE
postgresql-1-deploy                 0/1     Completed   0          5m48s
postgresql-1-lf7qt                  1/1     Running     0          5m40s
rails-pgsql-persistent-1-build      0/1     Completed   0          5m49s
rails-pgsql-persistent-1-deploy     0/1     Completed   0          3m36s
rails-pgsql-persistent-1-hook-pre   0/1     Completed   0          3m28s
rails-pgsql-persistent-1-pjh6q      1/1     Running     0          3m14s

You can exit by pressing Ctrl+C

Once the deployment is complete you can now test the application and the persistent storage on Ceph:

URL http://rails-pgsql-persistent-my-database-app.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/articles/

The articles and comments are saved in a PostgreSQL database which stores its table spaces on the Ceph RBD volume provisioned using the ocs-storagecluster-ceph-rbd storageclass during the application deployment.

To log in, use the following credentials:

username: openshift
password: secret

If you want to clean your screen before continuing, just execute: clear