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.

90 lines
5.8 KiB

  1. # vSphere CSI Driver
  2. vSphere CSI driver allows you to provision volumes over a vSphere deployment. The Kubernetes historic in-tree cloud provider is deprecated and will be removed in future versions.
  3. To enable vSphere CSI driver, uncomment the `vsphere_csi_enabled` option in `group_vars/all/vsphere.yml` and set it to `true`.
  4. To set the number of replicas for the vSphere CSI controller, you can change `vsphere_csi_controller_replicas` option in `group_vars/all/vsphere.yml`.
  5. You need to source the vSphere credentials you use to deploy your machines that will host Kubernetes.
  6. | Variable | Required | Type | Choices | Default | Comment |
  7. |---------------------------------------------|----------|---------|----------------------------|---------------------------|----------------------------------------------------------------|
  8. | external_vsphere_vcenter_ip | TRUE | string | | | IP/URL of the vCenter |
  9. | external_vsphere_vcenter_port | TRUE | string | | "443" | Port of the vCenter API |
  10. | external_vsphere_insecure | TRUE | string | "true", "false" | "true" | set to "true" if the host above uses a self-signed cert |
  11. | external_vsphere_user | TRUE | string | | | User name for vCenter with required privileges |
  12. | external_vsphere_password | TRUE | string | | | Password for vCenter |
  13. | external_vsphere_datacenter | TRUE | string | | | Datacenter name to use |
  14. | external_vsphere_kubernetes_cluster_id | TRUE | string | | "kubernetes-cluster-id" | Kubernetes cluster ID to use |
  15. | vsphere_cloud_controller_image_tag | TRUE | string | | "latest" | Kubernetes cluster ID to use |
  16. | vsphere_syncer_image_tag | TRUE | string | | "v1.0.2" | Syncer image tag to use |
  17. | vsphere_csi_attacher_image_tag | TRUE | string | | "v1.1.1" | CSI attacher image tag to use |
  18. | vsphere_csi_controller | TRUE | string | | "v1.0.2" | CSI controller image tag to use |
  19. | vsphere_csi_controller_replicas | TRUE | integer | | 1 | Number of pods Kubernetes should deploy for the CSI controller |
  20. | vsphere_csi_liveness_probe_image_tag | TRUE | string | | "v1.1.0" | CSI liveness probe image tag to use |
  21. | vsphere_csi_provisioner_image_tag | TRUE | string | | "v1.2.2" | CSI provisioner image tag to use |
  22. | vsphere_csi_node_driver_registrar_image_tag | TRUE | string | | "v1.1.0" | CSI node driver registrat image tag to use |
  23. | vsphere_csi_driver_image_tag | TRUE | string | | "v1.0.2" | CSI driver image tag to use |
  24. ## Usage example
  25. To test the dynamic provisioning using vSphere CSI driver, make sure to create a [storage policy](https://github.com/kubernetes/cloud-provider-vsphere/blob/master/docs/book/tutorials/kubernetes-on-vsphere-with-kubeadm.md#create-a-storage-policy) and [storage class](https://github.com/kubernetes/cloud-provider-vsphere/blob/master/docs/book/tutorials/kubernetes-on-vsphere-with-kubeadm.md#create-a-storageclass), then apply the following manifest:
  26. ```yml
  27. ---
  28. apiVersion: v1
  29. kind: PersistentVolumeClaim
  30. metadata:
  31. name: csi-pvc-vsphere
  32. spec:
  33. accessModes:
  34. - ReadWriteOnce
  35. resources:
  36. requests:
  37. storage: 1Gi
  38. storageClassName: Space-Efficient
  39. ---
  40. apiVersion: v1
  41. kind: Pod
  42. metadata:
  43. name: nginx
  44. spec:
  45. containers:
  46. - image: nginx
  47. imagePullPolicy: IfNotPresent
  48. name: nginx
  49. ports:
  50. - containerPort: 80
  51. protocol: TCP
  52. volumeMounts:
  53. - mountPath: /var/lib/www/html
  54. name: csi-data-vsphere
  55. volumes:
  56. - name: csi-data-vsphere
  57. persistentVolumeClaim:
  58. claimName: csi-pvc-vsphere
  59. readOnly: false
  60. ```
  61. Apply this conf to your cluster: ```kubectl apply -f nginx.yml```
  62. You should see the PVC provisioned and bound:
  63. ```ShellSession
  64. $ kubectl get pvc
  65. NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
  66. csi-pvc-vsphere Bound pvc-dc7b1d21-ee41-45e1-98d9-e877cc1533ac 1Gi RWO Space-Efficient 10s
  67. ```
  68. And the volume mounted to the Nginx Pod (wait until the Pod is Running):
  69. ```ShellSession
  70. kubectl exec -it nginx -- df -h | grep /var/lib/www/html
  71. /dev/sdb 976M 2.6M 907M 1% /var/lib/www/html
  72. ```
  73. ## More info
  74. For further information about the vSphere CSI Driver, you can refer to the official [vSphere Cloud Provider documentation](https://cloud-provider-vsphere.sigs.k8s.io/container_storage_interface.html).