×

Red Hat OpenShift Service on AWS (ROSA) (classic architecture) and Red Hat OpenShift Service on AWS (ROSA) support storing persistent volumes with either Amazon Web Services (AWS) Elastic Block Store (EBS) or AWS Elastic File System (EFS).

Using persistent volumes

Use the following procedures to create a file, store it on a persistent volume in your cluster, and confirm that it still exists after pod failure and re-creation.

Viewing a persistent volume claim

  1. Navigate to the cluster’s OpenShift web console.

  2. Click Storage in the left menu, then click PersistentVolumeClaims to see a list of all the persistent volume claims.

  3. Click a persistence volume claim to see the size, access mode, storage class, and other additional claim details.

    The access mode is ReadWriteOnce (RWO). This means that the volume can only be mounted to one node and the pod or pods can read and write to the volume.

Storing your file

  1. In the OSToy app console, click Persistent Storage in the left menu.

  2. In the Filename box, enter a file name with a .txt extension, for example test-pv.txt.

  3. In the File contents box, enter a sentence of text, for example OpenShift is the greatest thing since sliced bread!.

  4. Click Create file.

    cloud experts storage ostoy createfile
  5. Scroll to Existing files on the OSToy app console.

  6. Click the file you created to see the file name and contents.

    cloud experts storage ostoy viewfile

Crashing the pod

  1. On the OSToy app console, click Home in the left menu.

  2. Click Crash pod.

Confirming persistent storage

  1. Wait for the pod to re-create.

  2. On the OSToy app console, click Persistent Storage in the left menu.

  3. Find the file you created, and open it to view and confirm the contents.

    cloud experts storage ostoy existingfile
Verification

The deployment YAML file shows that we mounted the directory /var/demo_files to our persistent volume claim.

  1. Retrieve the name of your front-end pod by running the following command:

    $ oc get pods
  2. Start a secure shell (SSH) session in your container by running the following command:

    $ oc rsh <pod_name>
  3. Go to the directory by running the following command:

    $ cd /var/demo_files
  4. Optional: See all the files you created by running the following command:

    $ ls
  5. Open the file to view the contents by running the following command:

    $ cat test-pv.txt
  6. Verify that the output is the text you entered in the OSToy app console.

    Example terminal
    $ oc get pods
    NAME                                  READY     STATUS    RESTARTS   AGE
    ostoy-frontend-5fc8d486dc-wsw24       1/1       Running   0          18m
    ostoy-microservice-6cf764974f-hx4qm   1/1       Running   0          18m
    
    $ oc rsh ostoy-frontend-5fc8d486dc-wsw24
    
    $ cd /var/demo_files/
    
    $ ls
    lost+found   test-pv.txt
    
    $ cat test-pv.txt
    OpenShift is the greatest thing since sliced bread!

Ending the session

  • Type exit in your terminal to quit the session and return to the CLI.

Additional resources