Bootstrap FreeKB - OpenShift - Create Shared Volume using a YAML template file
OpenShift - Create Shared Volume using a YAML template file

Updated:   |  OpenShift articles

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

A persistent volume (PV) is the "physical" volume (such as a hard disk drive or solid state drive) on the host machine (node) that stores your persistent data, whereas a persistent volume claim (PVC) is a reference to a persistent volume, used by a pod. A Shared Volume contains both a Persistent Volume and a Persistent Volume Claim and is typically used for an Amazon Web Services (AWS) Elastic File System (EFS).

 

A  JSON or YAML file that contains key value pairs used to create an object, such as a config map, deployment, a project, a pod, a route, a secret, a service, et cetera. These files are known as templates. The oc explain command can be used to get the list of keys that can be used in the JSON or YAML template file.

oc explain sharedvolumes

 

And then more details on each key can be displayed.

oc explain sharedvolumes.spec

 

Before you can create a Shared Volume, you must first install the Amazon Web Services (AWS) Elastic File System (EFS) Storage Class. The oc get storageclass command can be used to determine if the AWS EFS Storage Class has been installed (it will be the Storage Class that has the efs.csi.aws.com PROVISIONER).

If accessMode is not used, the access mode will be set to ReadWriteMany (RWX). Or, you can specify the access modes you would like the Persistent Volume to support.

  • ReadWriteOnce (RWO) - The volume may only be mounted on a single node
  • ReadWriteOncePod (RWOP) - The volume may only be mounted on a single pod
  • ReadOnlyMany (ROX) - The volume may be mounted on different nodes
  • ReadWriteMany (RWX) - The volume can be mounted on different nodes

If volumeMode is not used, the volume mode will be set to Filesystem. Or, you can specify the volume mode you would like the Persistent Volume to use.

  • Filesystem (default, files are stored anywhere on the storage device)
  • Block (files are stored in a dediated block on the storage device, which may result in improved read/write performance)

claimRef is optional, and can be used to create one or more Persistent Volume Claims that use the Persistent Volume.

apiVersion must be aws-efs.managed.openshift.io/v1alpha1

AVOID TROUBLE

accessPointID and fileSystemID must be between 8 - 40 alpha numeric characters and must be an exact match of the Amazon Web Services (AWS) Elastic File System (EFS) ID and the Elastic File System Access Point ID.

apiVersion: aws-efs.managed.openshift.io/v1alpha1
kind: SharedVolume
metadata:
  name: my-shared-volume
  namespace: default
spec:
  accessPointID: fsap-0123456789abcdef
  fileSystemID: fs-0123cdef

 

The oc get sharedvolumes (or oc get sv) command should now list the Shared Volume.

~]$ oc get sharedvolumes
AME                 FILE SYSTEM   ACCESS POINT            PHASE   CLAIM                      MESSAGE
my-shared-volume    fs-0123cdef   fsap-0123456789abcdef   Ready   my-persistent-volume-claim 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 72a126 in the box below so that we can be sure you are a human.