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.

77 lines
2.6 KiB

  1. # GCP Persistent Disk CSI Driver
  2. The GCP Persistent Disk CSI driver allows you to provision volumes for pods with a Kubernetes deployment over Google Cloud Platform. The CSI driver replaces to volume provioning done by the in-tree azure cloud provider which is deprecated.
  3. To deploy GCP Persistent Disk CSI driver, uncomment the `gcp_pd_csi_enabled` option in `group_vars/all/gcp.yml` and set it to `true`.
  4. ## GCP Persistent Disk Storage Class
  5. If you want to deploy the GCP Persistent Disk storage class to provision volumes dynamically, you should set `persistent_volumes_enabled` in `group_vars/k8s_cluster/k8s_cluster.yml` to `true`.
  6. ## GCP credentials
  7. In order for the CSI driver to provision disks, you need to create for it a service account on GCP with the appropriate permissions.
  8. Follow these steps to configure it:
  9. ```ShellSession
  10. # This will open a web page for you to authenticate
  11. gcloud auth login
  12. export PROJECT=nameofmyproject
  13. gcloud config set project $PROJECT
  14. git clone https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver $GOPATH/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
  15. export GCE_PD_SA_NAME=my-gce-pd-csi-sa
  16. export GCE_PD_SA_DIR=/my/safe/credentials/directory
  17. ./deploy/setup-project.sh
  18. ```
  19. The above will create a file named `cloud-sa.json` in the specified `GCE_PD_SA_DIR`. This file contains the service account with the appropriate credentials for the CSI driver to perform actions on GCP to request disks for pods.
  20. You need to provide this file's path through the variable `gcp_pd_csi_sa_cred_file` in `inventory/mycluster/group_vars/all/gcp.yml`
  21. You can now deploy Kubernetes with Kubespray over GCP.
  22. ## GCP PD CSI Driver test
  23. To test the dynamic provisioning using GCP PD CSI driver, make sure to have the storage class deployed (through persistent volumes), and apply the following manifest:
  24. ```yml
  25. ---
  26. kind: PersistentVolumeClaim
  27. apiVersion: v1
  28. metadata:
  29. name: podpvc
  30. spec:
  31. accessModes:
  32. - ReadWriteOnce
  33. storageClassName: csi-gce-pd
  34. resources:
  35. requests:
  36. storage: 1Gi
  37. ---
  38. apiVersion: v1
  39. kind: Pod
  40. metadata:
  41. name: web-server
  42. spec:
  43. containers:
  44. - name: web-server
  45. image: nginx
  46. volumeMounts:
  47. - mountPath: /var/lib/www/html
  48. name: mypvc
  49. volumes:
  50. - name: mypvc
  51. persistentVolumeClaim:
  52. claimName: podpvc
  53. readOnly: false
  54. ```
  55. ## GCP PD documentation
  56. You can find the official GCP Persistent Disk CSI driver installation documentation here: [GCP PD CSI Driver](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/docs/kubernetes/user-guides/driver-install.md
  57. )