Container Service: Developing an Application - Persistent Storage

Overview

The Container Service provides storage for applications that need to store stateful information. Amazon's Elastic File Storage (EFS) is utilized by default. Applications requiring higher performance storage can specify the 'gp2' type, which will utilize Amazon's Elastic Block Storage (EBS).

Note: EBS can only be used by a single pod. Applications requiring multiple pods to access the same storage should utilize EFS.

For sensitive information like passwords or tokens, please use Secrets. Container Service documentation on secrets is available here.

The OpenShift documentation for claiming and utilizing persistent storage is here.

Setting Up Storage Volumes

To acquire storage using the OpenShift CLI, use the oc create -f myfile.yaml command where the yaml file will follow the format specified here. Some notes:

  • Do not specify a 'volumeName', one will be created automatically.
  • To use EBS, specify an 'accessMode' of 'ReadWriteOnce'. A volume will be created with the size specified in the 'storage' field. The volume will be limited to that size.
  • To use EFS, specify an 'accessMode' of 'ReadWriteMany'. A directory will be created on an EFS volume maintained by the Container Service. Your directory will not be limited to that size and can grow unlimited.
  • Information on price of storage is available here.

Using A Claim Within A Project

After making the claim using the yaml specified above, open the deployment config for the app that will be using the storage. Click on ‘Attach storage’ in the lower left-hand corner:

attach storage

In the resulting form, specify the mount point for the claim within your apps.

Note:If you are modifying a multi-pod deployment config, all pods will mount the claim at the same place, unless otherwise specified. After you click ‘Attach’, your pods will be automatically redeployed with the storage attached.

The deployment config will now look like this:

storage attached

Adding Files To Storage

Container Service documentation on moving files to or from persistent storage is available here.

Last Updated: 
Tuesday, June 2, 2020