Published: September 26, 2019
Updated: September 26, 2019
Tags: OpenStack, Rancher, Kubernetes
4 min read

OpenStack Cinder As A Persistent Storage For Rancher

A follow-up to blog post Adding OpenStack Cloud Provider To Rancher Cluster

Tested on Rancher 2.2.4

Storage In Containerized World

Docker containers are transient, once they fulfill their purpose and deleted, they do no retain any data.
With the adoption and the growing use cases of Docker, an option to store container data was required.

There are 2 popular mechanisms for persistent storage for containers:

  1. Docker Volumes [1] - Areas on the filesystem which are managed by Docker. Volumes are managed directly by Docker binaries, can be shared between containers, works cross platform, easy to backup/migrate and contain drivers that allow to store data on various storage backends (one of them is OpenStack Cinder).
  2. Bind Mounts [2] - A file/directory which are bound to a container. They rely on the host machine's filesystem and can not be shared between containers.

Persistent Storage In Kubernetes

Kubernets leverages docker volumes in order to provide persistent storage capabilities.

Persistent Volume [3] is a chunk of storage that was provisioned by a user or Storage Class [4] which is exposed to the cluster.

Persistent Volume Claim is request for storage that consumes Persistent Volume. Claims can request specific size and access mode.

OpenStack Cinder As A Persistent Kubernetes Storage Backend

Kubernetes natively supports OpenStack Cinder as one of its storage backends [5].

OpenStack Cinder based volumes only support a single access mode ReadWriteOnce, a single container may only read and write to a volume, the data can not be shared between containers.

Configuring OpenStack Cinder As A Storage Backend in Rancher

Requires to have OpenStack configured as a Kubernetes Cloud Provider

Navigate to Rancher dashboard and select the cluster containing an OpenStack cloud provider:
Rancher Cluster Dashboard

Add Storage Class

Select Storage > Storage Classes from the top menu:
Rancher Cluster Storage Menu Entry
Add a s
torage class to cluster by clicking on Add Class:
Rancher Cluster Storage Class Dashboard
Add Storage Class view:
Rancher Add Storage Class View
Select OpenStack Cinder from the dropdown menu:
Rancher Add Storage Class View - Provisoner Selection
OpenStack Cinder Storage Class Options:
Rancher Add OpenStack Cinder Storage Class View

  • Name - Name given to Storage Class
  • Decription - Description of Storage Class Entity
  • Provisioner - Kubernetes Storage Provisioner to use
  • Paramaters - Extra params for Storage Class:
    • Volume Type - Cinder backend to use for Storage Class (OpenStack Cinder has an option to expose multiple backends to the operator [6])
    • Availability Zone - Nova availability that contains Cinder backend
  • Customize - Advanced options:
    • Reclaim Policy - Set if volumes should be deleted after containers are deleted
    • Mount Options - Additional mount options passed to Docker volume

Once Storage Class is created it will appear:
Rancher Populated Storage Class View

Testing OpenStack Cinder Storage

There are several ways of creating persistent volumes which are not all covered in this section

In order to verify that your Storage Class allows to create persistent volumes, we'll deploy a workload (refer to workload deployment [7]

Creating Persistent Volume Claim

During workload creation, we can create a pvc based on previously configured storage class:
Create persistent volume claim
Add Volume Claim view:
Add Volume Claim view

  • Name - Name given to volume claim
  • Description - Description of volume claim
  • Source - Source which fulfills the volume claim
    • Storage Class - Storage class to use for volume claim
    • Capacity - Storage capacity to provision
  • Customize - Set access mode of volume.
    OpenStack Cinder supports only 'Single Node Read-Write'.

Configure volume mount on created persistent volume:
Volume mount in Volumes view

  • Volume Name - Name given to volume
  • Volume Type - Kubernetes volume types [8], in our case it will be persistentVolumeClaim
  • Mount Point - Mount point to be used in container
  • Sub Path in Volume - Sub path inside root directory of volume [9]
  • Read Only - Set Read Only to mount

If the storage configuration is valid, a workload should be spawned and it should appear in the Persistent Volumes in Cluster dashboard:
Persistent Volumes view
The created volume will appear in OpenStack dashboard as well:
OpenStack Volumes view

Summary

Docker volumes allow persistent storage capabilities in Kubernetes.
OpenStack Cinder is a block based storage which is used as part of OpenStack clouds.
Kuberenetes Storage Classes allow operators to leverage various storage solutions.


  1. Docker documentation - Using Volumes ↩︎

  2. Docker documentation - Using bind mounts ↩︎

  3. Kubernetes documentation - Persistent Volumes ↩︎

  4. Kubernetes documentation - Storage Classes ↩︎

  5. Kubernetes documentation - Storage Classes - OpenStack Cinder ↩︎

  6. OpenStack documentation - Cinder - Configure multiple-storage back ends ↩︎

  7. vkhitrin.com - Deploying Rancher On OpenStack - Deploy Workload ↩︎

  8. Kubernetes documentation - Volumes - Types of Volumes ↩︎

  9. Kubernetes documentation - Volumes - Using subPath ↩︎