Skip to content

Commit 6db9dbf

Browse files
authored
Merge pull request #403 from davidz627/feature/migrationConfig
Add user guide for pre-provisioned volumes
2 parents 330efe6 + 3b5bb4f commit 6db9dbf

File tree

4 files changed

+110
-15
lines changed

4 files changed

+110
-15
lines changed

docs/kubernetes/user-guides/basic.md

+1-14
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,7 @@ Kubernetes 1.14.
66

77
## Install Driver
88

9-
1. [One-time per project] Create GCP service account for the CSI driver and set required roles
10-
```
11-
$ PROJECT=your-project-here # GCP project
12-
$ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create
13-
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key
14-
$ ./deploy/setup-project.sh
15-
```
16-
17-
2. Deploy driver to Kubernetes Cluster
18-
```
19-
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key
20-
$ GCE_PD_DRIVER_VERSION=stable # Driver version to deploy
21-
$ ./deploy/kubernetes/deploy-driver.sh
22-
```
9+
See [instructions](driver-install.md)
2310

2411
## Zonal PD example
2512
This example provisions a zonal PD in both single-zone and regional clusters.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Kubernetes Driver Installation Guide
2+
3+
## Install Driver
4+
5+
1. [One-time per project] Create GCP service account for the CSI driver and set required roles
6+
```
7+
$ PROJECT=your-project-here # GCP project
8+
$ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create
9+
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key
10+
$ ./deploy/setup-project.sh
11+
```
12+
13+
2. Deploy driver to Kubernetes Cluster
14+
```
15+
$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key
16+
$ GCE_PD_DRIVER_VERSION=stable # Driver version to deploy
17+
$ ./deploy/kubernetes/deploy-driver.sh
18+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Kubernetes Pre-Provisioned Disks User Guide
2+
3+
This guide gives a simple example on how to use this driver with disks that have
4+
been pre-provisioned by an administrator.
5+
6+
## Install Driver
7+
8+
See [instructions](driver-install.md)
9+
10+
## Pre-Provision a Disk
11+
12+
If you have not already pre-provisioned a disk on GCP you can do that now.
13+
14+
1. Create example PD
15+
16+
```bash
17+
gcloud compute disks create test-disk --zone=us-central1-c --size=200Gi
18+
```
19+
20+
## Create Persistent Volume for Disk
21+
22+
1. Create example Storage Class
23+
24+
```bash
25+
kubectl apply -f ./examples/kubernetes/demo-zonal-sc.yaml
26+
```
27+
28+
2. Create example Persistent Volume
29+
30+
**Note:** The `volumeHandle` and `nodeSelectorTerms` values should be generated
31+
based on the project, zone\[s\], and PD name of the disk created. `storage` value
32+
should be generated based on the size of the underlying disk
33+
34+
**Regional PD Note:** The volume handle format is different and the
35+
`nodeSelectorTerms` must contain both zones the PD is supported in.
36+
37+
```yaml
38+
apiVersion: v1
39+
kind: PersistentVolume
40+
metadata:
41+
name: my-pv
42+
annotations:
43+
pv.kubernetes.io/provisioned-by: pd.csi.storage.gke.io
44+
spec:
45+
storageClassName: "csi-gce-pd"
46+
capacity:
47+
storage: 200Gi # MODIFY THIS LINE
48+
accessModes:
49+
- ReadWriteOnce
50+
nodeAffinity:
51+
required:
52+
nodeSelectorTerms:
53+
- matchExpressions:
54+
- key: topology.gke.io/zone
55+
operator: In
56+
values:
57+
- us-central1-c # MODIFY THIS LINE
58+
# - us-central1-b <For Regional PD>
59+
csi:
60+
driver: "pd.csi.storage.gke.io"
61+
# volumeHandle: "projects/${PROJECT}/regions/us-central1/disks/test-disk" <For Regional PD>
62+
volumeHandle: "projects/${PROJECT}/zones/us-central1-c/disks/test-disk" # MODIFY THIS LINE
63+
```
64+
65+
Then `kubectl apply` this YAML.
66+
67+
## Use Persistent Volume In Pod
68+
69+
1. Create example PVC and Pod
70+
71+
```bash
72+
kubectl apply -f ./examples/kubernetes/demo-pod.yaml
73+
```
74+
75+
2. Verify PV is created and bound to PVC
76+
77+
```bash
78+
$ kubectl get pvc
79+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
80+
podpvc Bound podpvc 200Gi RWO csi-gce-pd 9s
81+
```
82+
83+
3. Verify pod is created and in `RUNNING` state (it may take a few minutes to
84+
get to running state)
85+
86+
```bash
87+
$ kubectl get pods
88+
NAME READY STATUS RESTARTS AGE
89+
web-server 1/1 Running 0 1m
90+
```

examples/kubernetes/demo-pod.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ spec:
88
storageClassName: csi-gce-pd
99
resources:
1010
requests:
11-
storage: 6Gi
11+
storage: 200Gi
1212

1313
---
1414

0 commit comments

Comments
 (0)