You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.6 KiB

  1. # Cinder CSI Driver
  2. Cinder CSI driver allows you to provision volumes over an OpenStack deployment. The Kubernetes historic in-tree cloud provider is deprecated and will be removed in future versions.
  3. To enable Cinder CSI driver, uncomment the `cinder_csi_enabled` option in `group_vars/all/openstack.yml` and set it to `true`.
  4. To set the number of replicas for the Cinder CSI controller, you can change `cinder_csi_controller_replicas` option in `group_vars/all/openstack.yml`.
  5. You need to source the OpenStack credentials you use to deploy your machines that will host Kubernetes: `source path/to/your/openstack-rc` or `. path/to/your/openstack-rc`.
  6. Make sure the hostnames in your `inventory` file are identical to your instance names in OpenStack. Otherwise [cinder](https://docs.openstack.org/cinder/latest/) won't work as expected.
  7. If you want to deploy the cinder provisioner used with Cinder CSI Driver, you should set `persistent_volumes_enabled` in `group_vars/k8s_cluster/k8s_cluster.yml` to `true`.
  8. You can now run the kubespray playbook (cluster.yml) to deploy Kubernetes over OpenStack with Cinder CSI Driver enabled.
  9. ## Usage example
  10. To check if Cinder CSI Driver works properly, see first that the cinder-csi pods are running:
  11. ```ShellSession
  12. $ kubectl -n kube-system get pods | grep cinder
  13. csi-cinder-controllerplugin-7f8bf99785-cpb5v 5/5 Running 0 100m
  14. csi-cinder-nodeplugin-rm5x2 2/2 Running 0 100m
  15. ```
  16. Check the associated storage class (if you enabled persistent_volumes):
  17. ```ShellSession
  18. $ kubectl get storageclass
  19. NAME PROVISIONER AGE
  20. cinder-csi cinder.csi.openstack.org 100m
  21. ```
  22. You can run a PVC and an Nginx Pod using this file `nginx.yaml`:
  23. ```yml
  24. ---
  25. apiVersion: v1
  26. kind: PersistentVolumeClaim
  27. metadata:
  28. name: csi-pvc-cinderplugin
  29. spec:
  30. accessModes:
  31. - ReadWriteOnce
  32. resources:
  33. requests:
  34. storage: 1Gi
  35. storageClassName: cinder-csi
  36. ---
  37. apiVersion: v1
  38. kind: Pod
  39. metadata:
  40. name: nginx
  41. spec:
  42. containers:
  43. - image: nginx
  44. imagePullPolicy: IfNotPresent
  45. name: nginx
  46. ports:
  47. - containerPort: 80
  48. protocol: TCP
  49. volumeMounts:
  50. - mountPath: /var/lib/www/html
  51. name: csi-data-cinderplugin
  52. volumes:
  53. - name: csi-data-cinderplugin
  54. persistentVolumeClaim:
  55. claimName: csi-pvc-cinderplugin
  56. readOnly: false
  57. ```
  58. Apply this conf to your cluster: ```kubectl apply -f nginx.yml```
  59. You should see the PVC provisioned and bound:
  60. ```ShellSession
  61. $ kubectl get pvc
  62. NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
  63. csi-pvc-cinderplugin Bound pvc-f21ad0a1-5b7b-405e-a462-48da5cb76beb 1Gi RWO cinder-csi 8s
  64. ```
  65. And the volume mounted to the Nginx Pod (wait until the Pod is Running):
  66. ```ShellSession
  67. kubectl exec -it nginx -- df -h | grep /var/lib/www/html
  68. /dev/vdb 976M 2.6M 958M 1% /var/lib/www/html
  69. ```
  70. ## Compatibility with in-tree cloud provider
  71. It is not necessary to enable OpenStack as a cloud provider for Cinder CSI Driver to work.
  72. Though, you can run both the in-tree openstack cloud provider and the Cinder CSI Driver at the same time. The storage class provisioners associated to each one of them are differently named.
  73. ## Cinder v2 support
  74. For the moment, only Cinder v3 is supported by the CSI Driver.
  75. ## More info
  76. For further information about the Cinder CSI Driver, you can refer to this page: [Cloud Provider OpenStack](https://github.com/kubernetes/cloud-provider-openstack/blob/master/docs/cinder-csi-plugin/using-cinder-csi-plugin.md).