|
| 1 | +:_mod-docs-content-type: ASSEMBLY |
| 2 | +[id="cloud-experts-deploying-application-storage"] |
| 3 | += Tutorial: Persistent volumes for cluster storage |
| 4 | +include::_attributes/attributes-openshift-dedicated.adoc[] |
| 5 | +:context: cloud-experts-deploying-application-storage |
| 6 | + |
| 7 | +toc::[] |
| 8 | + |
| 9 | +//rosaworkshop.io content metadata |
| 10 | +//Brought into ROSA product docs 2024-04-30 |
| 11 | + |
| 12 | +{rosa-classic-first} and Red Hat OpenShift Service on AWS (ROSA) support storing persistent volumes with either link:https://aws.amazon.com/ebs/[Amazon Web Services (AWS) Elastic Block Store (EBS)] or link:https://aws.amazon.com/efs/[AWS Elastic File System (EFS)]. |
| 13 | + |
| 14 | +== Using persistent volumes |
| 15 | +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. |
| 16 | + |
| 17 | +=== Viewing a persistent volume claim |
| 18 | +. Navigate to the cluster's OpenShift web console. |
| 19 | +. Click *Storage* in the left menu, then click *PersistentVolumeClaims* to see a list of all the persistent volume claims. |
| 20 | +. Click a persistence volume claim to see the size, access mode, storage class, and other additional claim details. |
| 21 | ++ |
| 22 | +[NOTE] |
| 23 | +==== |
| 24 | +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. |
| 25 | +==== |
| 26 | + |
| 27 | +=== Storing your file |
| 28 | + |
| 29 | +. In the OSToy app console, click *Persistent Storage* in the left menu. |
| 30 | +. In the *Filename* box, enter a file name with a `.txt` extension, for example `test-pv.txt`. |
| 31 | +. In the *File contents* box, enter a sentence of text, for example `OpenShift is the greatest thing since sliced bread!`. |
| 32 | +. Click *Create file*. |
| 33 | ++ |
| 34 | +image::cloud-experts-storage-ostoy-createfile.png[] |
| 35 | ++ |
| 36 | +.Verification |
| 37 | +. Scroll to *Existing files* on the OSToy app console. |
| 38 | +. Click the file you created to see the file name and contents. |
| 39 | ++ |
| 40 | +image::cloud-experts-storage-ostoy-viewfile.png[] |
| 41 | + |
| 42 | +=== Crashing the pod |
| 43 | + |
| 44 | +. On the OSToy app console, click *Home* in the left menu. |
| 45 | +. Click *Crash pod*. |
| 46 | + |
| 47 | +=== Confirming persistent storage |
| 48 | + |
| 49 | +. Wait for the pod to re-create. |
| 50 | +. On the OSToy app console, click *Persistent Storage* in the left menu. |
| 51 | +. Find the file you created, and open it to view and confirm the contents. |
| 52 | ++ |
| 53 | +image::cloud-experts-storage-ostoy-existingfile.png[] |
| 54 | + |
| 55 | +.Verification |
| 56 | +The deployment YAML file shows that we mounted link:https://github.com/openshift-cs/rosaworkshop/blob/master/rosa-workshop/ostoy/yaml/ostoy-frontend-deployment.yaml#L61[the directory] `/var/demo_files` to our persistent volume claim. |
| 57 | + |
| 58 | +. Retrieve the name of your front-end pod by running the following command: |
| 59 | ++ |
| 60 | +[source,terminal] |
| 61 | +---- |
| 62 | +$ oc get pods |
| 63 | +---- |
| 64 | ++ |
| 65 | +. Start a secure shell (SSH) session in your container by running the following command: |
| 66 | ++ |
| 67 | +[source,terminal] |
| 68 | +---- |
| 69 | +$ oc rsh <pod_name> |
| 70 | +---- |
| 71 | ++ |
| 72 | +. Go to the directory by running the following command: |
| 73 | ++ |
| 74 | +[source,terminal] |
| 75 | +---- |
| 76 | +$ cd /var/demo_files |
| 77 | +---- |
| 78 | ++ |
| 79 | +. *Optional:* See all the files you created by running the following command: |
| 80 | ++ |
| 81 | +[source,terminal] |
| 82 | +---- |
| 83 | +$ ls |
| 84 | +---- |
| 85 | ++ |
| 86 | +. Open the file to view the contents by running the following command: |
| 87 | ++ |
| 88 | +[source,terminal] |
| 89 | +---- |
| 90 | +$ cat test-pv.txt |
| 91 | +---- |
| 92 | ++ |
| 93 | +. Verify that the output is the text you entered in the OSToy app console. |
| 94 | ++ |
| 95 | +.Example terminal |
| 96 | +[source,terminal] |
| 97 | +---- |
| 98 | +$ oc get pods |
| 99 | +NAME READY STATUS RESTARTS AGE |
| 100 | +ostoy-frontend-5fc8d486dc-wsw24 1/1 Running 0 18m |
| 101 | +ostoy-microservice-6cf764974f-hx4qm 1/1 Running 0 18m |
| 102 | +
|
| 103 | +$ oc rsh ostoy-frontend-5fc8d486dc-wsw24 |
| 104 | +
|
| 105 | +$ cd /var/demo_files/ |
| 106 | +
|
| 107 | +$ ls |
| 108 | +lost+found test-pv.txt |
| 109 | +
|
| 110 | +$ cat test-pv.txt |
| 111 | +OpenShift is the greatest thing since sliced bread! |
| 112 | +---- |
| 113 | + |
| 114 | +=== Ending the session |
| 115 | + |
| 116 | +* Type `exit` in your terminal to quit the session and return to the CLI. |
| 117 | + |
| 118 | +[role="_additional-resources"] |
| 119 | +== Additional resources |
| 120 | +* For more information about persistent volume storage, see xref:../../storage/understanding-persistent-storage.adoc#persistent-volumes_understanding-persistent-storage[Understanding persistent storage]. |
| 121 | +* For more information about ROSA storage options, see xref:../../storage/index.adoc#storage-overview[Storage overview]. |
0 commit comments