Cinder CSI
Cinder is an Openstack cloud storage service that can be used to provision block storage to Kubernetes Nodes running within an environment with Openstack Cinder. To use Cinder a Kubernetes storage class and the required Cinder CSI driver needs to be installed within the Kubernetes Clusters along with an encrypted Openstack RC configuration for accessing the OpenStack Cloud.
The steps below will take you through cloning the Cinder CSI GitHub repository and installing the driver. Please note, Cinder CSI may also be install using helm charts.
To install the Cinder CSI driver you must have GitHub and Kubectl installed on the host that will be used to access the cluster.
Install Cinder CSI Driver
The first step is to clone the cinder repository from GitHub to a host that that has Kubectl installed and can access your cluster.
git clone https://github.com/kubernetes/cloud-provider-openstack.gitOnce the repository has been cloned a new Kubernetes Secret must be created that contains the Openstack RC for connecting to the Openstack cloud.
Within the cloned directory navigate to the manifest files for the CSI driver cloud-provider-openstack/manifests``cinder-csi-plugin/. In the the CSI driver folder you will need to create the secret which contains the rc file of our openstack cloud. Once the file has been created it needs to be converted to base64.
Create the Openstack RC file by running the command below:
[root@master00 cinder-csi-plugin]# cat cloud.conf[Global]username = YOUR_USERpassword = YOUR_PASSWORDdomain-name = defaultauth-url = https://YOUR_DU_URL/keystone/v3tenant-id = YOUR_TENANT_IDregion = YOUR_REGIONSave and close the file and then use the command below to encrypt your file with base64 so it can be use as a secret.
cat cloud.conf | base64 |tr -d '\n'W0dsb2JhbF0KdXNlcm5hbWUgPSBZT1VSX1VTRVIKcGFzc3dvcmQgPSBZT1VSX1BBU1NXT1JECmRvbWFpbi1uYW1lID0gZGVmYXVsdAphdXRoLXVybCA9IGh0dHBzOi8vWU9VUl9EVV9VUkwva2V5c3RvbmUvdjMKdGVuYW50LWlkID0gWU9VUl9URU5BTlRfSUQKcmVnaW9uID0gWU9VUl9SRUdJT04KUse VI or VIM to copy the contents of the encoded Openstack RC configuration and add the string into the data field of the csi-secret-cinderplugin.yamlfile.
root@master00 cinder-csi-plugin# cat csi-secret-cinderplugin.yaml# This YAML file contains secret objects,# which are necessary to run csi cinder plugin.kindSecretapiVersionv1metadata namecloud-config namespacekube-systemdata cloud.confW0dsb2JhbF0KdXNlcm5hbWUgPSBZT1VSX1VTRVIKcGFzc3dvcmQgPSBZT1VSX1BBU1NXT1JECmRvbWFpbi1uYW1lID0gZGVmYXVsdAphdXRoLXVybCA9IGh0dHBzOi8vWU9VUl9EVV9VUkwva2V5c3RvbmUvdjMKdGVuYW50LWlkID0gWU9VUl9URU5BTlRfSUQKcmVnaW9uID0gWU9VUl9SRUdJT04KThe secret can now be added to the Kubernetes Cluster. To do this apply the cs-secret-cinderplugin.yaml file using Kubectl , this will create a secret name cloud-config in kube-system namespace.
kubectl create -f manifests/cinder-csi-plugin/csi-secret-cinderplugin.yamlThe next step is to apply the remaining manifest files to deploy the csi-cinder controller and related plugins.
The manifests will create a set of cluster roles, cluster role bindings, and statefulsets to communicate with openstack and the Cinder service.
Apply all of the manifest using Kubectl Apply at the parent directory of the cloned Cinder repository.
$ kubectl -f manifests/cinder-csi-plugin/ applyTo validate the CSI driver is installed and running runKubectl get pods -n kube-systemand look for the cinder pods below.
csi-cinder-controllerplugin-0 6/6 Running 6 8dcsi-cinder-nodeplugin-4w6w6 3/3 Running 3 8dcsi-cinder-nodeplugin-gk5nf 3/3 Running 3 8dTo get information about CSI Drivers running in a cluster
$ kubectl get csidrivers.storage.k8s.ioNAME CREATED ATcinder.csi.openstack.org 2019-07-29T09:02:40ZCreate Cinder Storage Class
Once the the Cinder CSI driver is installed a Storage Class needs to be setup to enable consumption of the driver. Follow the steps below to setup a storage class.
- Log into your Platform9 SaaS Management Plane
- Navigate to Storage and click
Add Storage Class - Select the target cluster, enter a name, select if the storage class should be the cluster defused and enter
cinder.csi.openstack.orgas the provisioner - Click next,
- Review the YAML file before applying it to the cluster.
Example Cinder Storage Class.
apiVersionstorage.k8s.io/v1kindStorageClassmetadata namecinder-example annotations storageclass.kubernetes.io/is-default-class"true"provisionercinder.csi.openstack.org