The purpose of this tutorial is to explain how to deploy csi-plugin for cinder storage.
Inside you k8s cluster clone the following repo:
git clone https://github.com/kubernetes/cloud-provider-openstack.git
Then you will see cloud-provider-openstack
folder. Now we need to create a secret file for the plugin to access our tenant.
vim cloud-provider-openstack/manifests/cinder-csi-plugin/cloud.conf
Now copy the following to cloud.conf
and make the nessary changes for your tenant:
[Global]
username = YOUR_USER
password = YOUR_PASSWORD
domain-name = "ruh2 or jed1"
auth-url = "JED or RUH API URL"
tenant-name = "TENANT-NAME"
tenant-id = "TENANT-ID"
region = "RegionOne"
The API url. ruh: https://api-ruh2-vdc.bluvalt.com/identity/v3 jed: https://api-jed1-vdc.bluvalt.com/identity/v3
Now we need to transfeer this file into secret so that k8s can understand it by the following command.
cat cloud-provider-openstack/manifests/cinder-csi-plugin/cloud.conf | base64 |tr -d '\n'
Now we need to add this secret to csi-secret-cinderplugin.yaml
file.
vim cloud-provider-openstack/manifests/cinder-csi-plugin/csi-secret-cinderplugin.yaml
The result file will look like this:
# This YAML file contains secret objects,
# which are necessary to run csi cinder plugin.
kind: Secret
apiVersion: v1
metadata:
name: cloud-config
namespace: kube-system
data:
cloud.conf: W0dsb2JhbF0KdXNlcm5hbWUgPSBZT1VSX1VTRVIKcGFzc3dvcmQgPSBZT1VSX1BBU1NXT1JECmRvbWFpbi1uYW1lID0gICJET01BSU4iCmF1dGgtdXJsID0gIkpFRCBvciBSVUggQVBJIFVSTCIKdGVuYW50LW5hbWUgPSAiVEVOQU5ULU5BTUUiCnRlbmFudC1pZCA9ICJURU5BTlQtSUQiCnJlZ2lvbiA9ICAiUkVHSU9OIgo=
Then apply the csi-secret-cinderplugin.yaml
manafist by the following command:
kubectl apply -f cloud-provider-openstack/manifests/cinder-csi-plugin/csi-secret-cinderplugin.yaml
To confairm the secret is deployed, you can run this command:
kubectl get secrets -n kube-system | grep cloud
And the result as follow:
Now apply all the remaining csi plugin manafists inside this folder cloud-provider-openstack/manifests/cinder-csi-plugin
cd into this file and run the following command:
kubectl apply -f .
And to confairm all went good run the following command and see the result:
kubectl get pods -n kube-system | grep csi
Now you can create cinder storage class
with the following manafist:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: cinder-storage
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: cinder.csi.openstack.org
allowVolumeExpansion: true
volumeBindingMode: Immediate
apply it and confairm it is deployed:
Great job! now you can create Persistent Volume Claim
with storageClassName: cinder-storage
.
We recommend to delete volume manually from OpenStack after deleting the PVC with the following commands:
openstack volume list --status <status>
openstack volume delete <volume name or ID>
Our recommendation based on this issue with csi-cinder plugin Click here.