DEV Community

Cover image for How to use Persistent Storage in OpenShift?
Sagar Jadhav
Sagar Jadhav

Posted on • Edited on • Originally published at developersthought.in

How to use Persistent Storage in OpenShift?

Objective

  • Deploy Mongodb Application
  • Create PersistentVolumeClaim
  • Assign PersistentVolumeClaim to Mongodb Application
  • Verify that data gets stored in Persistent Storage

Step 1: Set up OpenShift environment

Go to Katacoda.com & click on start scenario

Step 2: Update environment permissions

setenforce 0
Enter fullscreen mode Exit fullscreen mode

Step 3: Deploy mongodb application

oc new-app --name mongo -l app=db --docker-image=centos/mongodb-36-centos7 -e MONGODB_ADMIN_PASSWORD=secret
Enter fullscreen mode Exit fullscreen mode

Step 4: List pods

oc get pods
Enter fullscreen mode Exit fullscreen mode

Step 5: Describe pod

oc describe pod <POD_NAME>
Enter fullscreen mode Exit fullscreen mode

Step 6: Create PersistentVolumeClaim & assign it to mongodb application

oc set volume dc/mongo --add --name=<PVC_NAME> -t pvc --claim-size=10Gi  --overwrite --claim-mode="ReadWriteMany"
Enter fullscreen mode Exit fullscreen mode
Example: oc set volume dc/mongo --add --name=mongo-volume-1 -t pvc --claim-size=10Gi  --overwrite --claim-mode="ReadWriteMany"
Enter fullscreen mode Exit fullscreen mode

Step 7: List PersistentVolumeClaims (PVC's)

oc get pvc
Enter fullscreen mode Exit fullscreen mode

Step 8: List PersistentVolumes (PV's)

oc get pv
Enter fullscreen mode Exit fullscreen mode

Step 9: Describe pod

oc describe pod <POD_NAME>
Enter fullscreen mode Exit fullscreen mode

Step 10: Describe PersistentVolume (PV)

oc describe pv <PV_NAME>
Enter fullscreen mode Exit fullscreen mode

Step 11: List files

Go to PV location

ls
Enter fullscreen mode Exit fullscreen mode

Top comments (0)