Managing Persistent Volumes

Hands-On Lab

 

Length

01:00:00

Difficulty

Intermediate

Hank and the rest of the Strickland Propane team would like to move customer data stored in MariaDB from a local database to OpenShift, but before they risk it, they would like a demonstration on how to deploy databases in OpenShift with persistent storage.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Managing Persistent Volumes

Introduction

Hank and the rest of the Strickland Propane team would like to move customer data stored in MariaDB from a local database to OpenShift, but before they risk it, they would like a demonstration on how to deploy databases in OpenShift with persistent storage.

Solution

  • Log in to the OpenShift cluster using the credentials provided on the hands-on lab page:

    ssh cloud_user@<IP_ADDRESS>
  • Become the root user:

    sudo -i
  • Create projects associated with the labs:

    for i in strickland-propane arlen-high megalomart
        do
        oc new-project $i --description="Arlen Tx Engineering project"
    done
  • Switch to the strickland-propane namespace

    oc project strickland-propane
  • Create an object definition:

    vi strickland-pv.yml
  • Paste the following as the contents of the file:

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: strickland-pv
    spec:
      capacity:
        storage: 1Gi
      accessModes:
      - ReadWriteOnce
      nfs:
        path: /home/data/persistent01
        server: ip-10-0-2-206.ec2.internal
      persistentVolumeReclaimPolicy: Recycle
  • Save and close the file:

    :wq
  • Create the persistent volume:

    oc create -f strickland-pv.yml
  • Verify it was created:

    oc get pv
  • Launch the demo, using the specified parameters from the instructions:

    oc new-app --template=mariadb-persistent --param=MYSQL_USER=bossmanbuck 
    --param=MYSQL_PASSWORD=propanerules --param=MYSQL_DATABASE=strickland --param=MYSQL_ROOT_PASSWORD=mrsliz
  • Verify the database is running:

    oc get pods
  • Verify the persistent volume is created correctly.

    First, we need to get the name of our deployment config:

    oc get dc
  • Verify if the volume is bound to the mariadb database:

    oc volumes dc/mariadb
  • Show the volume name:

    oc get pv

Conclusion

Congratulations, you've completed this hands-on lab!