Persistent Storage Using AWS Elastic Block Store

You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see [4]

You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see [4]

Overview

OKD supports AWS Elastic Block Store volumes (EBS). You can provision your OKD cluster with persistent storage using AWS EC2. Some familiarity with Kubernetes and AWS is assumed.

Before creating persistent volumes using AWS, OKD must first be properly configured for AWS ElasticBlockStore.

The Kubernetes persistent volume framework allows administrators to provision a cluster with persistent storage and gives users a way to request those resources without having any knowledge of the underlying infrastructure. AWS Elastic Block Store volumes can be provisioned dynamically. Persistent volumes are not bound to a single project or namespace; they can be shared across the OKD cluster. Persistent volume claims, however, are specific to a project or namespace and can be requested by users.

High-availability of storage in the infrastructure is left to the underlying storage provider.

Provisioning

Storage must exist in the underlying infrastructure before it can be mounted as a volume in OKD. After ensuring OpenShift is configured for AWS Elastic Block Store, all that is required for OpenShift and AWS is an AWS EBS volume ID and the **PersistentVolume** API.

Creating the Persistent Volume

AWS does not support the ‘Recycle’ reclaim policy.

You must define your persistent volume in an object definition before creating it in OKD:

Example 1. Persistent Volume Object Definition Using AWS

  1. apiVersion: "v1"
  2. kind: "PersistentVolume"
  3. metadata:
  4. name: "pv0001" (1)
  5. spec:
  6. capacity:
  7. storage: "5Gi" (2)
  8. accessModes:
  9. - "ReadWriteOnce"
  10. awsElasticBlockStore: (3)
  11. fsType: "ext4" (4)
  12. volumeID: "vol-f37a03aa" (5)
1The name of the volume. This will be how it is identified via persistent volume claims or from pods.
2The amount of storage allocated to this volume.
3This defines the volume type being used, in this case the awsElasticBlockStore plug-in.
4File system type to mount.
5This is the AWS volume that will be used.

Changing the value of the fstype parameter after the volume has been formatted and provisioned can result in data loss and pod failure.

Save your definition to a file, for example aws-pv.yaml, and create the persistent volume:

  1. # oc create -f aws-pv.yaml
  2. persistentvolume "pv0001" created

Verify that the persistent volume was created:

  1. # oc get pv
  2. NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE
  3. pv0001 <none> 5Gi RWO Available 2s

Users can then request storage using persistent volume claims, which can now utilize your new persistent volume.

Persistent volume claims only exist in the user’s namespace and can only be referenced by a pod within that same namespace. Any attempt to access a persistent volume from a different namespace causes the pod to fail.

Volume Format

Before OKD mounts the volume and passes it to a container, it checks that it contains a file system as specified by the **fsType** parameter in the persistent volume definition. If the device is not formatted with the file system, all data from the device is erased and the device is automatically formatted with the given file system.

This allows using unformatted AWS volumes as persistent volumes, because OKD formats them before the first use.

Maximum Number of EBS Volumes on a Node

By default, OKD supports a maximum of 39 EBS volumes attached to one node. This limit is consistent with the AWS Volume Limits.

OKD can be configured to have a higher limit by setting the environment variable KUBE_MAX_PD_VOLS. However, AWS requires a particular naming scheme (AWS Device Naming) for attached devices, which only supports a maximum of 52 volumes. This limits the number of volumes that can be attached to a node via OKD to 52.