This guide describes how to add Cinder as backing storage for persistent volumes in Kubernetes and how to implement that into a deployment or pod.
- A CityCloud account.
- A Kubernetes cluster deploy, either through RaaS (Rancher as a Service) or a cluster created by other means.
- Kubectl software installed.
In this guide, we will follow the below steps:
- Inventory any pre-existing storage classes.
- Create a Cinder backed storage class (and make it default).
- Create a persistent volume.
- Create a persistent storage claim.
- Configure a pod to use our volume.
Inventory any pre-existing storage classes.
We need to be aware of any pre-existing storage classes to make a few decisions:
- Do we make our storage class default instead?
- Or do we keep the existing one as is and define which class to use later on in our deployment / pod definition?
To check if there are any storage classes in our cluster, we'll run this:
Create a Cinder backed storage class (and make it default).
We need to let Kubernetes know that there is a Cinder backend and that it should be used as default.
This is not overly complex:
- Create applicable yaml.
- Apply to the cluster.
A example yaml :
This will create a default storageclass and when creating a persistent volume a volume in the "CityCloud Control Panel" and it'll be attached the appropriate Kubernetes node.
Create a persistent volume.
We will need to create a persistent volume that we'll later claim and attach to our pod.
This specifies a few important things: capacity, storage class and access modes.
As we created a default storage class earlier, there is no need to specify it. But it is best practise.
The access mode specifies that only one node can allocate and use the volumes.
Create a persistent volume claim.
To be able to assign the created volume to our pod, we'll need to claim it.
Configure pod to use our volume.
The last piece of the puzzle is to actually attach the volume to a pod: