|
| 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 | +``` |
0 commit comments