Skip to content

Commit 7eee10d

Browse files
authored
Merge pull request #120 from jingxu97/deploy
Add snapshot deployment support
2 parents 69de5c7 + 1ec5d48 commit 7eee10d

File tree

7 files changed

+124
-3
lines changed

7 files changed

+124
-3
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,39 @@ NAME READY STATUS RESTARTS AGE
9090
web-server 1/1 Running 0 1m
9191
```
9292

93+
### Snapshot Example
94+
1. Create example Default Snapshot Class
95+
```
96+
$ kubectl create -f ./examples/kubernetes/demo-defaultsnapshotclass.yaml
97+
```
98+
2. Create a snapshot of the PVC created in above example
99+
```
100+
$ kubectl create -f ./examples/kubernetes/demo-snapshot.yaml
101+
```
102+
3. Verify Snapshot is created and is ready to use
103+
```
104+
$ k get volumesnapshots demo-snapshot-podpvc -o yaml
105+
apiVersion: snapshot.storage.k8s.io/v1alpha1
106+
kind: VolumeSnapshot
107+
metadata:
108+
creationTimestamp: 2018-10-05T16:59:26Z
109+
generation: 1
110+
name: demo-snapshot-podpvc
111+
namespace: default
112+
113+
...
114+
115+
status:
116+
creationTime: 2018-10-05T16:59:27Z
117+
ready: true
118+
restoreSize: 6Gi
119+
120+
```
121+
4. Create a new volume from the snapshot
122+
```
123+
$ kubectl create -f ./examples/kubernetes/demo-restore-snapshot.yaml
124+
```
125+
93126
## Kubernetes Development
94127

95128
### Manual

deploy/kubernetes/dev/controller.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@ spec:
1515
spec:
1616
serviceAccount: csi-controller-sa
1717
containers:
18+
- name: csi-snapshotter
19+
imagePullPolicy: Always
20+
image: quay.io/k8scsi/csi-snapshotter:v0.4.0
21+
args:
22+
- "--v=5"
23+
- "--csi-address=$(ADDRESS)"
24+
env:
25+
- name: ADDRESS
26+
value: /csi/csi.sock
27+
volumeMounts:
28+
- name: socket-dir
29+
mountPath: /csi
30+
1831
- name: csi-provisioner
1932
imagePullPolicy: Always
20-
image: quay.io/k8scsi/csi-provisioner:v0.3.1
33+
image: quay.io/k8scsi/csi-provisioner:v0.4.1
2134
args:
2235
- "--v=5"
2336
- "--provisioner=com.google.csi.gcepd"

deploy/kubernetes/dev/node.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
securityContext:
3838
privileged: true
3939
imagePullPolicy: Always
40-
image: gcr.io/dyzz-csi-staging/csi/gce-pd-driver:latest
40+
image: gcr.io/dyzz-csi-staging/csi/gce-pd-driver:latest
4141
args:
4242
- "--v=5"
4343
- "--endpoint=$(CSI_ENDPOINT)"
@@ -94,4 +94,4 @@ spec:
9494
- name: sys
9595
hostPath:
9696
path: /sys
97-
type: Directory
97+
type: Directory

deploy/kubernetes/dev/setup-cluster.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: system:csi-external-snapshotter
5+
rules:
6+
- apiGroups: ["snapshot.storage.k8s.io"]
7+
resources: ["volumesnapshotclasses"]
8+
verbs: ["get", "list", "watch"]
9+
- apiGroups: ["snapshot.storage.k8s.io"]
10+
resources: ["volumesnapshotcontents"]
11+
verbs: ["create", "get", "list", "watch", "update", "delete"]
12+
- apiGroups: ["snapshot.storage.k8s.io"]
13+
resources: ["volumesnapshots"]
14+
verbs: ["get", "list", "watch", "update"]
15+
- apiGroups: ["apiextensions.k8s.io"]
16+
resources: ["customresourcedefinitions"]
17+
verbs: ["create", "list", "watch", "delete"]
18+
- apiGroups: [""]
19+
resources: ["events"]
20+
verbs: ["list", "watch", "create", "update", "patch"]
21+
- apiGroups: ["storage.k8s.io"]
22+
resources: ["storageclasses"]
23+
verbs: ["watch", "get", "list"]
24+
- apiGroups: ["admissionregistration.k8s.io"]
25+
resources: ["mutatingwebhookconfigurations"]
26+
verbs: ["create"]
27+
---
28+
129
kind: ClusterRole
230
apiVersion: rbac.authorization.k8s.io/v1
331
metadata:
@@ -67,4 +95,19 @@ subjects:
6795
roleRef:
6896
kind: ClusterRole
6997
name: system:csi-external-provisioner
98+
apiGroup: rbac.authorization.k8s.io
99+
100+
---
101+
102+
kind: ClusterRoleBinding
103+
apiVersion: rbac.authorization.k8s.io/v1
104+
metadata:
105+
name: csi-controller-snapshotter-binding
106+
subjects:
107+
- kind: ServiceAccount
108+
name: csi-controller-sa
109+
namespace: default
110+
roleRef:
111+
kind: ClusterRole
112+
name: system:csi-external-snapshotter
70113
apiGroup: rbac.authorization.k8s.io
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: snapshot.storage.k8s.io/v1alpha1
2+
kind: VolumeSnapshotClass
3+
metadata:
4+
annotations:
5+
snapshot.storage.kubernetes.io/is-default-class: "true"
6+
name: default-snapshot-class
7+
snapshotter: com.google.csi.gcepd
8+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: PersistentVolumeClaim
2+
apiVersion: v1
3+
metadata:
4+
name: restore-snapshot
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
storageClassName: csi-gce-pd
9+
resources:
10+
requests:
11+
storage: 6Gi
12+
dataSource:
13+
kind: VolumeSnapshot
14+
name: demo-snapshot-podpvc
15+
apiGroup: snapshot.storage.k8s.io
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: snapshot.storage.k8s.io/v1alpha1
2+
kind: VolumeSnapshot
3+
metadata:
4+
name: demo-snapshot-podpvc
5+
spec:
6+
source:
7+
kind: PersistentVolumeClaim
8+
name: podpvc
9+

0 commit comments

Comments
 (0)