|
6 | 6 |
|
7 | 7 | 1. [One-time per project] Create GCP service account for the CSI driver and set required roles
|
8 | 8 |
|
9 |
| -``` |
10 |
| -$ PROJECT=your-project-here # GCP project |
11 |
| -$ GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create |
12 |
| -$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key |
13 |
| -$ ./deploy/setup-project.sh |
14 |
| -``` |
| 9 | + ``` |
| 10 | + PROJECT=your-project-here # GCP project |
| 11 | + GCE_PD_SA_NAME=my-gce-pd-csi-sa # Name of the service account to create |
| 12 | + GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key |
| 13 | + ./deploy/setup-project.sh |
| 14 | + ``` |
15 | 15 |
|
16 |
| -2. Deploy driver to Kubernetes Cluster |
| 16 | +1. Deploy driver to Kubernetes Cluster |
17 | 17 |
|
18 |
| -``` |
19 |
| -$ GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key |
20 |
| -$ GCE_PD_DRIVER_VERSION=alpha # Driver version to deploy |
21 |
| -$ ./deploy/kubernetes/deploy-driver.sh |
22 |
| -``` |
| 18 | + ``` |
| 19 | + GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to get the service account key |
| 20 | + GCE_PD_DRIVER_VERSION=alpha # Driver version to deploy |
| 21 | + ./deploy/kubernetes/deploy-driver.sh |
| 22 | + ``` |
23 | 23 |
|
24 | 24 | ### Snapshot Example
|
25 | 25 |
|
26 |
| -**Create Storage Class:** |
| 26 | +1. Create `StorageClass` |
27 | 27 |
|
28 |
| -If you haven't created a `StorageClass` yet, create one first: |
| 28 | + If you haven't created a `StorageClass` yet, create one first: |
29 | 29 |
|
30 |
| -```console |
31 |
| -kubectl apply -f ./examples/kubernetes/demo-zonal-sc.yaml |
32 |
| -``` |
| 30 | + ```console |
| 31 | + kubectl apply -f ./examples/kubernetes/demo-zonal-sc.yaml |
| 32 | + ``` |
33 | 33 |
|
34 |
| -**Create Default VolumeSnapshotClass:** |
| 34 | +1. Create default `VolumeSnapshotClass` |
35 | 35 |
|
36 |
| -```console |
37 |
| -kubectl create -f ./examples/kubernetes/snapshot/default_volumesnapshotclass.yaml |
38 |
| -``` |
| 36 | + ```console |
| 37 | + kubectl create -f ./examples/kubernetes/snapshot/default-volumesnapshotclass.yaml |
| 38 | + ``` |
39 | 39 |
|
40 |
| -**Create source PVC:** |
| 40 | +1. Create source PVC |
41 | 41 |
|
42 |
| -```console |
43 |
| -kubectl create -f ./examples/kubernetes/snapshot/source_pvc.yaml |
44 |
| -``` |
| 42 | + ```console |
| 43 | + kubectl create -f ./examples/kubernetes/snapshot/source-pvc.yaml |
| 44 | + ``` |
45 | 45 |
|
46 |
| -**Generate sample data:** |
| 46 | +1. Generate sample data |
47 | 47 |
|
48 |
| -Create a sample pod with the source PVC. The source PVC is mounted into `/demo/data` directory of this pod. This pod will create a file `sample-file.txt` in `/demo/data` directory. |
| 48 | + Create a sample pod with the source PVC. The source PVC is mounted into `/demo/data` directory of this pod. This pod will create a file `sample-file.txt` in `/demo/data` directory. |
49 | 49 |
|
50 |
| -```console |
51 |
| -kubectl create -f ./examples/kubernetes/snapshot/source_pod.yaml |
52 |
| -``` |
| 50 | + ```console |
| 51 | + kubectl create -f ./examples/kubernetes/snapshot/source-pod.yaml |
| 52 | + ``` |
53 | 53 |
|
54 |
| -Check if the file has been created successfully: |
| 54 | + Check if the file has been created successfully: |
55 | 55 |
|
56 |
| -```console |
57 |
| -$ kubectl exec source-pod -- ls /demo/data/ |
58 |
| -lost+found |
59 |
| -sample-file.txt |
60 |
| -``` |
| 56 | + ```console |
| 57 | + kubectl exec source-pod -- ls /demo/data/ |
| 58 | + ``` |
61 | 59 |
|
62 |
| -**Create a snapshot of the source PVC:** |
| 60 | + The output should be: |
63 | 61 |
|
64 |
| -```console |
65 |
| -kubectl create -f ./examples/kubernetes/snapshot/snapshot.yaml |
66 |
| -``` |
| 62 | + ``` |
| 63 | + lost+found |
| 64 | + sample-file.txt |
| 65 | + ``` |
67 | 66 |
|
68 |
| -**Verify Snapshot has been created and it is ready to use:** |
| 67 | +1. Create a `VolumeSnapshot` of the source PVC |
69 | 68 |
|
70 |
| -```console |
71 |
| -$ kubectl get volumesnapshot snapshot-source-pvc -o yaml |
72 |
| -apiVersion: snapshot.storage.k8s.io/v1alpha1 |
73 |
| -kind: VolumeSnapshot |
74 |
| -metadata: |
75 |
| - ... |
76 |
| - name: snapshot-source-pvc |
77 |
| - namespace: default |
78 |
| - ... |
79 |
| -spec: |
80 |
| - snapshotClassName: default-snapshot-class |
81 |
| - snapshotContentName: snapcontent-b408076b-720b-11e9-b9e3-42010a800014 |
82 |
| - ... |
83 |
| -status: |
84 |
| - creationTime: "2019-05-09T03:37:01Z" |
85 |
| - readyToUse: true |
86 |
| - restoreSize: 6Gi |
87 |
| -``` |
| 69 | + ```console |
| 70 | + kubectl create -f ./examples/kubernetes/snapshot/snapshot.yaml |
| 71 | + ``` |
88 | 72 |
|
89 |
| -**Restore the Snapshot into a new PVC:** |
| 73 | +1. Verify that `VolumeSnapshot` has been created and it is ready to use: |
90 | 74 |
|
91 |
| -Create a new PVC. Specify `spec.dataSource` section to restore from VolumeSnapshot `snapshot-source-pvc`. |
| 75 | + ```console |
| 76 | + kubectl get volumesnapshot snapshot-source-pvc -o yaml |
| 77 | + ``` |
92 | 78 |
|
93 |
| -```console |
94 |
| - kubectl create -f ./examples/kubernetes/snapshot/restored_pvc.yaml |
95 |
| -``` |
| 79 | + The output is similar to this: |
96 | 80 |
|
97 |
| -**Verify sample data has been restored:** |
| 81 | + ```yaml |
| 82 | + apiVersion: snapshot.storage.k8s.io/v1alpha1 |
| 83 | + kind: VolumeSnapshot |
| 84 | + metadata: |
| 85 | + ... |
| 86 | + name: snapshot-source-pvc |
| 87 | + namespace: default |
| 88 | + ... |
| 89 | + spec: |
| 90 | + snapshotClassName: default-snapshot-class |
| 91 | + snapshotContentName: snapcontent-b408076b-720b-11e9-b9e3-42010a800014 |
| 92 | + ... |
| 93 | + status: |
| 94 | + creationTime: "2019-05-09T03:37:01Z" |
| 95 | + readyToUse: true |
| 96 | + restoreSize: 6Gi |
| 97 | + ``` |
98 | 98 |
|
99 |
| -Create a sample pod with the restored PVC: |
| 99 | +1. Restore the `VolumeSnapshot` into a new PVC: |
100 | 100 |
|
101 |
| -```console |
102 |
| -kubectl create -f ./examples/kubernetes/snapshot/restored_pod.yaml |
103 |
| -``` |
| 101 | + Create a new PVC. Specify `spec.dataSource` section to restore from VolumeSnapshot `snapshot-source-pvc`. |
104 | 102 |
|
105 |
| -Check data has been restored in `/demo/data` directory: |
| 103 | + ```console |
| 104 | + kubectl create -f ./examples/kubernetes/snapshot/restored-pvc.yaml |
| 105 | + ``` |
106 | 106 |
|
107 |
| -```console |
108 |
| -$ kubectl exec restored-pod -- ls /demo/data/ |
109 |
| -lost+found |
110 |
| -sample-file.txt |
111 |
| -``` |
| 107 | +1. Verify sample data has been restored: |
| 108 | +
|
| 109 | + Create a sample pod with the restored PVC: |
| 110 | +
|
| 111 | + ```console |
| 112 | + kubectl create -f ./examples/kubernetes/snapshot/restored-pod.yaml |
| 113 | + ``` |
| 114 | +
|
| 115 | + Check data has been restored in `/demo/data` directory: |
| 116 | +
|
| 117 | + ```console |
| 118 | + kubectl exec restored-pod -- ls /demo/data/ |
| 119 | + ``` |
| 120 | +
|
| 121 | + Verify that the output is: |
| 122 | +
|
| 123 | + ``` |
| 124 | + lost+found |
| 125 | + sample-file.txt |
| 126 | + ``` |
0 commit comments