Skip to content

Commit 4d569a6

Browse files
authored
Merge pull request #1 from mattcary/fork-master
Fork master
2 parents 48ba715 + ac1f8c0 commit 4d569a6

20 files changed

+140
-147
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ that represents availability by zone.
7070
| Snapshots | Alpha | 1.13 | Any | v0.3.0 | Alpha |
7171
| Resize (Expand) | Alpha | 1.14 | 1.14 | v0.6.0 | Alpha |
7272
| Resize (Expand) | Beta | 1.16 | 1.16 | v0.7.0 | Stable |
73-
73+
| Snapshots | Beta | 1.17 | Any | master | Stable |
7474

7575
### Future Features
7676

deploy/kubernetes/base/controller.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ spec:
4848
volumeMounts:
4949
- name: socket-dir
5050
mountPath: /csi
51+
- name: csi-snapshotter
52+
image: gke.gcr.io/csi-snapshotter
53+
args:
54+
- "--v=5"
55+
- "--csi-address=/csi/csi.sock"
56+
volumeMounts:
57+
- name: socket-dir
58+
mountPath: /csi
5159
- name: gce-pd-driver
5260
# Don't change base image without changing pdImagePlaceholder in
5361
# test/k8s-integration/main.go

deploy/kubernetes/base/setup-cluster.yaml

+39-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ rules:
3636
- apiGroups: [""]
3737
resources: ["nodes"]
3838
verbs: ["get", "list", "watch"]
39-
39+
- apiGroups: ["snapshot.storage.k8s.io"]
40+
resources: ["volumesnapshots"]
41+
verbs: ["get", "list"]
42+
- apiGroups: ["snapshot.storage.k8s.io"]
43+
resources: ["volumesnapshotcontents"]
44+
verbs: ["get", "list"]
4045
---
4146

4247
kind: ClusterRoleBinding
@@ -193,3 +198,36 @@ roleRef:
193198
subjects:
194199
- kind: ServiceAccount
195200
name: csi-gce-pd-node-sa
201+
202+
---
203+
apiVersion: rbac.authorization.k8s.io/v1
204+
kind: ClusterRole
205+
metadata:
206+
name: csi-gce-pd-snapshotter-role
207+
rules:
208+
- apiGroups: [""]
209+
resources: ["events"]
210+
verbs: ["list", "watch", "create", "update", "patch"]
211+
# Secrets resource omitted since GCE PD snapshots does not require them
212+
- apiGroups: ["snapshot.storage.k8s.io"]
213+
resources: ["volumesnapshotclasses"]
214+
verbs: ["get", "list", "watch"]
215+
- apiGroups: ["snapshot.storage.k8s.io"]
216+
resources: ["volumesnapshotcontents"]
217+
verbs: ["create", "get", "list", "watch", "update", "delete"]
218+
- apiGroups: ["snapshot.storage.k8s.io"]
219+
resources: ["volumesnapshotcontents/status"]
220+
verbs: ["update"]
221+
---
222+
223+
kind: ClusterRoleBinding
224+
apiVersion: rbac.authorization.k8s.io/v1
225+
metadata:
226+
name: csi-gce-pd-controller-snapshotter-binding
227+
subjects:
228+
- kind: ServiceAccount
229+
name: csi-gce-pd-controller-sa
230+
roleRef:
231+
kind: ClusterRole
232+
name: csi-gce-pd-snapshotter-role
233+
apiGroup: rbac.authorization.k8s.io

deploy/kubernetes/overlays/alpha/controller_add_snapshotter.yaml

-17
This file was deleted.

deploy/kubernetes/overlays/alpha/kustomization.yaml

+1-14
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
bases:
44
- ../stable
5-
patches:
6-
- controller_add_snapshotter.yaml
7-
patchesJson6902:
8-
- target:
9-
group: rbac.authorization.k8s.io
10-
version: v1
11-
kind: ClusterRole
12-
name: csi-gce-pd-provisioner-role
13-
path: rbac_add_snapshots_to_provisioner.yaml
14-
resources:
15-
- rbac_add_snapshotter.yaml
16-
# Reapplying namespace transformer to include newly added RBAC rules.
17-
namespace:
18-
gce-pd-csi-driver
5+

deploy/kubernetes/overlays/alpha/rbac_add_snapshots_to_provisioner.yaml

-16
This file was deleted.

deploy/kubernetes/overlays/alpha/rbac_add_snapshotter.yaml

-48
This file was deleted.

deploy/kubernetes/overlays/prow-gke-release-staging-head/kustomization.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ images:
1818
- name: gke.gcr.io/csi-resizer
1919
newName: quay.io/k8scsi/csi-resizer
2020
newTag: "canary"
21+
- name: gke.gcr.io/csi-snapshotter
22+
newName: quay.io/k8scsi/csi-snapshotter
23+
newTag: "canary"

deploy/kubernetes/overlays/prow-gke-release-staging-rc/enable_sidecar_metrics.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@
1212
- op: add
1313
path: /spec/template/spec/containers/2/args/-
1414
value: "--metrics-address=:22013"
15+
16+
# for external-snapshotter
17+
- op: add
18+
path: /spec/template/spec/containers/3/args/-
19+
value: "--metrics-address=:22014"

deploy/kubernetes/overlays/prow-gke-release-staging-rc/kustomization.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ images:
1818
- name: gke.gcr.io/csi-resizer
1919
newName: gcr.io/gke-release-staging/csi-resizer
2020
newTag: "v0.5.0-gke.0"
21-
21+
- name: gke.gcr.io/csi-snapshotter
22+
newName: gcr.io/gke-release-staging/csi-snapshotter
23+
newTag: "v2.1.1-gke.0"
2224
patchesJson6902:
2325
- target:
2426
group: apps

deploy/kubernetes/overlays/stable/kustomization.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ images:
2020
- name: gke.gcr.io/csi-resizer
2121
newName: gke.gcr.io/csi-resizer
2222
newTag: "v0.4.0-gke.0"
23+
- name: gke.gcr.io/csi-snapshotter
24+
newName: gke.gcr.io/csi-snapshotter
25+
newTag: "v2.1.1-gke.0"

docs/kubernetes/user-guides/snapshots.md

+27-29
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
1-
# Kubernetes Snapshots User Guide (Alpha)
1+
# Kubernetes Snapshots User Guide (Beta)
22

3-
>**Attention:** VolumeSnapshot is an alpha feature. Make sure you have enabled it in Kubernetes API server using `--feature-gates=VolumeSnapshotDataSource=true` flag.
3+
>**Attention:** Attention: VolumeSnapshot is a Beta feature enabled by default in Kubernetes 1.17+. Attention: VolumeSnapshot is only available in the driver version "master".
44
5-
### Install Driver with alpha snapshot feature
6-
7-
1. [One-time per project] Create GCP service account for the CSI driver and set required roles
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-
```
15-
16-
1. Deploy driver to Kubernetes Cluster
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-
```
5+
### Install Driver with beta snapshot feature as described [here](driver-install.md)
236

247
### Snapshot Example
258

@@ -79,19 +62,34 @@
7962
The output is similar to this:
8063

8164
```yaml
82-
apiVersion: snapshot.storage.k8s.io/v1alpha1
8365
kind: VolumeSnapshot
8466
metadata:
85-
...
86-
name: snapshot-source-pvc
87-
namespace: default
88-
...
67+
creationTimestamp: "2020-05-13T21:48:08Z"
68+
finalizers:
69+
- snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
70+
- snapshot.storage.kubernetes.io/volumesnapshot-bound-protection
71+
generation: 1
72+
managedFields:
73+
- apiVersion: snapshot.storage.k8s.io/v1beta1
74+
fieldsType: FieldsV1
75+
fieldsV1:
76+
f:status:
77+
f:readyToUse: {}
78+
manager: snapshot-controller
79+
operation: Update
80+
time: "2020-05-13T21:49:42Z"
81+
name: snapshot-source-pvc
82+
namespace: default
83+
resourceVersion: "531499"
84+
selfLink: /apis/snapshot.storage.k8s.io/v1beta1/namespaces/default/volumesnapshots/snapshot-source-pvc
85+
uid: a10fd0ff-b868-4527-abe7-74d5b420731e
8986
spec:
90-
snapshotClassName: default-snapshot-class
91-
snapshotContentName: snapcontent-b408076b-720b-11e9-b9e3-42010a800014
92-
...
87+
source:
88+
persistentVolumeClaimName: source-pvc
89+
volumeSnapshotClassName: csi-gce-pd-snapshot-class
9390
status:
94-
creationTime: "2019-05-09T03:37:01Z"
91+
boundVolumeSnapshotContentName: snapcontent-a10fd0ff-b868-4527-abe7-74d5b420731e
92+
creationTime: "2020-05-13T21:48:43Z"
9593
readyToUse: true
9694
restoreSize: 6Gi
9795
```
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
apiVersion: snapshot.storage.k8s.io/v1alpha1
1+
apiVersion: snapshot.storage.k8s.io/v1beta1
22
kind: VolumeSnapshotClass
33
metadata:
4-
annotations:
5-
snapshot.storage.kubernetes.io/is-default-class: "true"
6-
name: default-snapshot-class
7-
snapshotter: pd.csi.storage.gke.io
4+
name: csi-gce-pd-snapshot-class
5+
driver: pd.csi.storage.gke.io
6+
deletionPolicy: Delete
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
apiVersion: snapshot.storage.k8s.io/v1alpha1
1+
apiVersion: snapshot.storage.k8s.io/v1beta1
22
kind: VolumeSnapshot
33
metadata:
44
name: snapshot-source-pvc
55
spec:
6+
volumeSnapshotClassName: csi-gce-pd-snapshot-class
67
source:
7-
kind: PersistentVolumeClaim
8-
name: source-pvc
8+
persistentVolumeClaimName: source-pvc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: snapshot.storage.k8s.io/v1beta1
2+
kind: VolumeSnapshotClass
3+
metadata:
4+
name: csi-gce-pd-snapshot-class
5+
driver: pd.csi.storage.gke.io
6+
deletionPolicy: Delete

test/k8s-integration/config/test-config-template.in

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
StorageClass:
22
FromFile: {{.StorageClassFile}}
3+
{{if .SnapshotClassFile }}
4+
SnapshotClass:
5+
FromFile: {{ .SnapshotClassFile }}
6+
{{end}}
37
DriverInfo:
48
Name: csi-gcepd
59
SupportedFsType:

test/k8s-integration/driver-config.go

+15-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
)
1010

1111
type driverConfig struct {
12-
StorageClassFile string
13-
Capabilities []string
12+
StorageClassFile string
13+
SnapshotClassFile string
14+
Capabilities []string
1415
}
1516

1617
const (
@@ -21,7 +22,7 @@ const (
2122

2223
// generateDriverConfigFile loads a testdriver config template and creates a file
2324
// with the test-specific configuration
24-
func generateDriverConfigFile(pkgDir, storageClassFile, deploymentStrat string) (string, error) {
25+
func generateDriverConfigFile(pkgDir, storageClassFile, snapshotClassFile, deploymentStrat string) (string, error) {
2526
// Load template
2627
t, err := template.ParseFiles(filepath.Join(pkgDir, testConfigDir, configTemplateFile))
2728
if err != nil {
@@ -51,7 +52,6 @@ func generateDriverConfigFile(pkgDir, storageClassFile, deploymentStrat string)
5152
}
5253

5354
/* Unsupported Capabilities:
54-
snapshotDataSource
5555
pvcDataSource
5656
RWX
5757
volumeLimits # PD Supports volume limits but test is very slow
@@ -72,9 +72,18 @@ func generateDriverConfigFile(pkgDir, storageClassFile, deploymentStrat string)
7272
return "", fmt.Errorf("got unknown deployment strat %s, expected gce or gke", deploymentStrat)
7373
}
7474

75+
var absSnapshotClassFilePath string
76+
// If snapshot class is passed in as argument, include snapshot specific driver capabiltiites.
77+
if snapshotClassFile != "" {
78+
caps = append(caps, "snapshotDataSource")
79+
// Update the absolute file path pointing to the snapshot class file, if it is provided as an argument.
80+
absSnapshotClassFilePath = filepath.Join(pkgDir, testConfigDir, snapshotClassFile)
81+
}
82+
7583
params := driverConfig{
76-
StorageClassFile: filepath.Join(pkgDir, testConfigDir, storageClassFile),
77-
Capabilities: caps,
84+
StorageClassFile: filepath.Join(pkgDir, testConfigDir, storageClassFile),
85+
SnapshotClassFile: absSnapshotClassFilePath,
86+
Capabilities: caps,
7887
}
7988

8089
// Write config file

0 commit comments

Comments
 (0)