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.

99 lines
3.5 KiB

  1. Cinder CSI Driver
  2. ===============
  3. 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.
  4. To enable Cinder CSI driver, uncomment the `cinder_csi_enabled` option in `group_vars/all/openstack.yml` and set it to `true`.
  5. 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`.
  6. 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`.
  7. 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.
  8. 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`.
  9. You can now run the kubespray playbook (cluster.yml) to deploy Kubernetes over OpenStack with Cinder CSI Driver enabled.
  10. ## Usage example ##
  11. To check if Cinder CSI Driver works properly, see first that the cinder-csi pods are running:
  12. ```
  13. $ kubectl -n kube-system get pods | grep cinder
  14. csi-cinder-controllerplugin-7f8bf99785-cpb5v 5/5 Running 0 100m
  15. csi-cinder-nodeplugin-rm5x2 2/2 Running 0 100m
  16. ```
  17. Check the associated storage class (if you enabled persistent_volumes):
  18. ```
  19. $ kubectl get storageclass
  20. NAME PROVISIONER AGE
  21. cinder-csi cinder.csi.openstack.org 100m
  22. ```
  23. You can run a PVC and an Nginx Pod using this file `nginx.yaml`:
  24. ```
  25. ---
  26. apiVersion: v1
  27. kind: PersistentVolumeClaim
  28. metadata:
  29. name: csi-pvc-cinderplugin
  30. spec:
  31. accessModes:
  32. - ReadWriteOnce
  33. resources:
  34. requests:
  35. storage: 1Gi
  36. storageClassName: cinder-csi
  37. ---
  38. apiVersion: v1
  39. kind: Pod
  40. metadata:
  41. name: nginx
  42. spec:
  43. containers:
  44. - image: nginx
  45. imagePullPolicy: IfNotPresent
  46. name: nginx
  47. ports:
  48. - containerPort: 80
  49. protocol: TCP
  50. volumeMounts:
  51. - mountPath: /var/lib/www/html
  52. name: csi-data-cinderplugin
  53. volumes:
  54. - name: csi-data-cinderplugin
  55. persistentVolumeClaim:
  56. claimName: csi-pvc-cinderplugin
  57. readOnly: false
  58. ```
  59. Apply this conf to your cluster: ```kubectl apply -f nginx.yml```
  60. You should see the PVC provisioned and bound:
  61. ```
  62. $ kubectl get pvc
  63. NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
  64. csi-pvc-cinderplugin Bound pvc-f21ad0a1-5b7b-405e-a462-48da5cb76beb 1Gi RWO cinder-csi 8s
  65. ```
  66. And the volume mounted to the Nginx Pod (wait until the Pod is Running):
  67. ```
  68. kubectl exec -it nginx -- df -h | grep /var/lib/www/html
  69. /dev/vdb 976M 2.6M 958M 1% /var/lib/www/html
  70. ```
  71. ## Compatibility with in-tree cloud provider ##
  72. It is not necessary to enable OpenStack as a cloud provider for Cinder CSI Driver to work.
  73. 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.
  74. ## Cinder v2 support ##
  75. For the moment, only Cinder v3 is supported by the CSI Driver.
  76. ## More info ##
  77. 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/using-cinder-csi-plugin.md).