Overview

OpenShift Origin supports VMWare vSphere’s VMDK (Virtual Machine Disk) Volumes. You can provision your OpenShift Origin cluster with persistent storage using VMWare vSphere. Some familiarity with Kubernetes and VMWare vSphere is assumed.

The OpenShift Origin 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. VMWare vSphere VMDK Volumes can be provisioned dynamically.

Persistent volumes are not bound to a single project or namespace; they can be shared across the OpenShift Origin 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.

Prerequisites

Before creating persistent volumes using VMWare vSphere, ensure your OpenShift Origin cluster meets the following requirements:

  • OpenShift Origin must first be configured for VMWare vSphere.

  • Each node host in the infrastructure must match the vSphere virtual machine name.

  • Each node host must be in the same resource group.

Create VMDK using one of the following methods before using them.

  • Create using vmkfstools:

    Access ESX through Secure Shell (SSH) and then use following command to create a vmdk:

    vmkfstools -c 2G /vmfs/volumes/DatastoreName/volumes/myDisk.vmdk
  • Create using vmware-vdiskmanager:

    shell vmware-vdiskmanager -c -t 0 -s 40GB -a lsilogic myDisk.vmdk

Provisioning

Storage must exist in the underlying infrastructure before it can be mounted as a volume in OpenShift Origin. After ensuring OpenShift Origin is configured for VMWare vSpehere, all that is required for OpenShift Origin and vSphere is a VM folder path, file system type, and the PersistentVolume API.

Creating the Persistent Volume

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

Persistent Volume Object Definition Using VMWare vShpere
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv0001 (1)
spec:
  capacity:
    storage: 2Gi (2)
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  vsphereVolume: (3)
    volumePath: "[datastore1] volumes/myDisk" (4)
    fsType: ext4 (5)
1 The name of the volume. This must be how it is identified via persistent volume claims or from pods.
2 The amount of storage allocated to this volume.
3 This defines the volume type being used (vsphereVolume plug-in, in this example). The vsphereVolume label is used to mount a vSphere VMDK Volume into pods. The contents of a volume are preserved when it is unmounted. It supports both VMFS and VSAN datastore.
4 This VMDK volume must exist.
5 File system type to mount (for example, ext4, xfs, and other file-systems).

Changing the value of the fsType parameter after the volume is formatted and provisioned can result in data loss and pod failure.

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

    $ oc create -f vsphere-pv.yaml
      persistentvolume "pv0001" created
  2. Verify that the persistent volume was created:

    $ oc get pv
    NAME    LABELS  CAPACITY  ACCESSMODES   STATUS    CLAIM   REASON  AGE
    pv0001  <none>  2Gi       RWO           Available                 2s

Now you can request storage using persistent volume claims, which can now use 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 OpenShift Origin mounts the volume and passes it to a container, it checks that the volume 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 unformatted VMWare vSphere volumes to be used as persistent volumes, because OpenShift Origin formats them before the first use.