|
3 | 3 | ## Install Driver
|
4 | 4 |
|
5 | 5 | 1. Clone the driver to your local machine
|
6 |
| -``` |
| 6 | + |
| 7 | +```console |
7 | 8 | $ git clone https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver $GOPATH/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
|
8 | 9 | ```
|
9 | 10 |
|
10 |
| -2. [One-time per project] Create GCP service account for the CSI driver and set required roles |
| 11 | +2. [One-time per project] Set up or use an existing service account: |
| 12 | + |
| 13 | +The driver requires a service account that has the following permissions and |
| 14 | +roles to function properly: |
| 15 | + |
11 | 16 | ```
|
| 17 | +compute.instances.get |
| 18 | +compute.instances.attachDisk |
| 19 | +compute.instances.detachDisk |
| 20 | +roles/compute.storageAdmin |
| 21 | +roles/iam.serviceAccountUser |
| 22 | +``` |
| 23 | + |
| 24 | +If there is a pre-existing service account with these roles for use then the |
| 25 | +service account key must be downloaded and made discoverable through environment |
| 26 | +variable |
| 27 | + |
| 28 | +``` |
| 29 | +$ gcloud iam service-accounts keys create "/my/safe/credentials/directory/cloud-sa.json" --iam-account "${my-iam-name}" --project "${my-project-name}" |
| 30 | +$ GCE_PD_SA_DIR=/my/safe/credentials/directory |
| 31 | +``` |
| 32 | + |
| 33 | +**Note**: The service account key *must* be named `cloud-sa.json` at driver deploy time |
| 34 | + |
| 35 | +However, if there is no pre-existing service account for use the provided script |
| 36 | +can be used to create a new service account with all the required permissions: |
| 37 | + |
| 38 | +```console |
12 | 39 | $ PROJECT=your-project-here # GCP project
|
13 | 40 | $ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create
|
14 | 41 | $ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key
|
15 | 42 | $ ./deploy/setup-project.sh
|
16 | 43 | ```
|
17 | 44 |
|
| 45 | +**Note**: The PD CSI Driver will be given the identity `my-gce-pd-csi-sa` during |
| 46 | +deployment, all actions performed by the driver will be performed as the |
| 47 | +specified service account |
| 48 | + |
18 | 49 | 3. Deploy driver to Kubernetes Cluster
|
19 |
| -``` |
| 50 | + |
| 51 | +```console |
20 | 52 | $ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key
|
21 | 53 | $ GCE_PD_DRIVER_VERSION=stable # Driver version to deploy
|
22 | 54 | $ ./deploy/kubernetes/deploy-driver.sh
|
23 |
| -``` |
| 55 | +``` |
| 56 | + |
| 57 | +## GCP Permissions Required |
| 58 | + |
| 59 | +The `setup-project.sh` script only needs to be run once per project to generate |
| 60 | +a service account for the driver. The user or service account running this |
| 61 | +script needs the following permissions: |
| 62 | + |
| 63 | +``` |
| 64 | +iam.serviceAccounts.list |
| 65 | +iam.serviceAccountKeys.create |
| 66 | +iam.roles.create |
| 67 | +iam.roles.get |
| 68 | +iam.roles.update |
| 69 | +``` |
| 70 | + |
| 71 | +If a service account provided to `setup-project.sh` does not already exist the |
| 72 | +additional permissions are required in order to create the new service account: |
| 73 | + |
| 74 | +``` |
| 75 | +resourcemanager.projects.getIamPolicy |
| 76 | +resourcemanager.projects.setIamPolicy |
| 77 | +iam.serviceAccounts.create |
| 78 | +iam.serviceAccounts.delete |
| 79 | +``` |
| 80 | + |
| 81 | +These permissions are not required if you already have a service account ready |
| 82 | +for use by the PD Driver. |
0 commit comments