vkhitrin.com

Technology And Ramblings

OpenStack Cinder As A Persistent Storage For Rancher



Tags: #OpenStack #Rancher #Kubernetes

Note: 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 are deleted, they do not retain any data. With the adoption and the growing use cases of Docker, an option to store container data was required.

There are two popular mechanisms for persistent storage for containers:

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

Persistent Storage In Kubernetes

Kubernetes leverages docker volumes to provide persistent storage capabilities.

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

A persistent Volume Claim is a request for storage that consumes Persistent Volume. Claims can request specific sizes and access modes.

OpenStack Cinder As A Persistent Kubernetes Storage Backend

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

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

Configuring OpenStack Cinder As A Storage Backend in Rancher

Note: Requires to have OpenStack configured as a Kubernetes Cloud Provider.

Navigate to the 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 storage class to the 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 - Provisioner Selection

OpenStack Cinder Storage Class Options: Rancher Add OpenStack Cinder Storage Class View

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

Testing OpenStack Cinder Storage

Note: There are several ways of creating persistent volumes, which are not all covered in this section.

To verify that your Storage Class allows creating persistent volumes, we’ll deploy a workload (refer to workload deployment from a previous post).

Creating Persistent Volume Claim

During workload creation, we can create a persistent volume claim based on a previously configured storage class: Create persistent volume claim

Add Volume Claim view: Add Volume Claim view

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

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 the OpenStack dashboard as well: OpenStack Volumes view

Summary

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

Back To Top