Skip to content

Commit 0021c22

Browse files
authored
Merge pull request #17 from xing-yang/yaml
Add example yaml files for deployment and testing
2 parents 631b9dc + 73600a6 commit 0021c22

File tree

6 files changed

+191
-0
lines changed

6 files changed

+191
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# This YAML file contains all API objects that are necessary to run external
2+
# CSI snapshotter.
3+
#
4+
# In production, this needs to be in separate files, e.g. service account and
5+
# role and role binding needs to be created once, while stateful set may
6+
# require some tuning.
7+
#
8+
# In addition, hostpath CSI driver is hardcoded as the CSI driver.
9+
apiVersion: v1
10+
kind: ServiceAccount
11+
metadata:
12+
name: csi-snapshotter
13+
14+
---
15+
kind: ClusterRole
16+
apiVersion: rbac.authorization.k8s.io/v1
17+
metadata:
18+
name: external-snapshotter-runner
19+
rules:
20+
- apiGroups: [""]
21+
resources: ["persistentvolumes"]
22+
verbs: ["get", "list", "watch", "create", "delete"]
23+
- apiGroups: [""]
24+
resources: ["persistentvolumeclaims"]
25+
verbs: ["get", "list", "watch", "update"]
26+
- apiGroups: ["storage.k8s.io"]
27+
resources: ["storageclasses"]
28+
verbs: ["get", "list", "watch"]
29+
- apiGroups: [""]
30+
resources: ["events"]
31+
verbs: ["list", "watch", "create", "update", "patch"]
32+
- apiGroups: [""]
33+
resources: ["endpoints"]
34+
verbs: ["list", "watch", "create", "update", "delete", "get"]
35+
- apiGroups: [""]
36+
resources: ["secrets"]
37+
verbs: ["get", "list"]
38+
- apiGroups: ["snapshot.storage.k8s.io"]
39+
resources: ["volumesnapshotclasses"]
40+
verbs: ["get", "list", "watch"]
41+
- apiGroups: ["snapshot.storage.k8s.io"]
42+
resources: ["volumesnapshotcontents"]
43+
verbs: ["create", "get", "list", "watch", "update", "delete"]
44+
- apiGroups: ["snapshot.storage.k8s.io"]
45+
resources: ["volumesnapshots"]
46+
verbs: ["get", "list", "watch", "update"]
47+
- apiGroups: ["apiextensions.k8s.io"]
48+
resources: ["customresourcedefinitions"]
49+
verbs: ["create", "list", "watch", "delete"]
50+
51+
---
52+
kind: ClusterRoleBinding
53+
apiVersion: rbac.authorization.k8s.io/v1
54+
metadata:
55+
name: csi-snapshotter-role
56+
subjects:
57+
- kind: ServiceAccount
58+
name: csi-snapshotter
59+
namespace: default
60+
roleRef:
61+
kind: ClusterRole
62+
name: external-snapshotter-runner
63+
apiGroup: rbac.authorization.k8s.io
64+
65+
---
66+
kind: Service
67+
apiVersion: v1
68+
metadata:
69+
name: csi-snapshotter
70+
labels:
71+
app: csi-snapshotter
72+
spec:
73+
selector:
74+
app: csi-snapshotter
75+
ports:
76+
- name: dummy
77+
port: 12345
78+
79+
---
80+
kind: StatefulSet
81+
apiVersion: apps/v1
82+
metadata:
83+
name: csi-snapshotter
84+
spec:
85+
serviceName: "csi-snapshotter"
86+
replicas: 1
87+
selector:
88+
matchLabels:
89+
app: csi-snapshotter
90+
template:
91+
metadata:
92+
labels:
93+
app: csi-snapshotter
94+
spec:
95+
serviceAccount: csi-snapshotter
96+
containers:
97+
- name: csi-provisioner
98+
image: xyang105/csi:csi-provisioner
99+
args:
100+
- "--provisioner=csi-hostpath"
101+
- "--csi-address=$(ADDRESS)"
102+
- "--connection-timeout=15s"
103+
env:
104+
- name: ADDRESS
105+
value: /csi/csi.sock
106+
imagePullPolicy: "IfNotPresent"
107+
volumeMounts:
108+
- name: socket-dir
109+
mountPath: /csi
110+
- name: csi-snapshotter
111+
image: xyang105/csi:csi-snapshotter
112+
args:
113+
- "--csi-address=$(ADDRESS)"
114+
- "--connection-timeout=15s"
115+
env:
116+
- name: ADDRESS
117+
value: /csi/csi.sock
118+
imagePullPolicy: "IfNotPresent"
119+
volumeMounts:
120+
- name: socket-dir
121+
mountPath: /csi
122+
- name: hostpath
123+
image: xyang105/csi:csi-hostpath
124+
args:
125+
- "--v=5"
126+
- "--endpoint=$(CSI_ENDPOINT)"
127+
- "--nodeid=$(KUBE_NODE_NAME)"
128+
env:
129+
- name: CSI_ENDPOINT
130+
value: unix:///csi/csi.sock
131+
- name: KUBE_NODE_NAME
132+
valueFrom:
133+
fieldRef:
134+
apiVersion: v1
135+
fieldPath: spec.nodeName
136+
imagePullPolicy: IfNotPresent
137+
securityContext:
138+
privileged: true
139+
volumeMounts:
140+
- name: socket-dir
141+
mountPath: /csi
142+
volumes:
143+
- name: socket-dir
144+
emptyDir:

examples/kubernetes/pvc.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: hpvc
5+
spec:
6+
storageClassName: csi-hostpath-sc
7+
accessModes:
8+
- ReadWriteOnce
9+
resources:
10+
requests:
11+
storage: 1Gi

examples/kubernetes/restore.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: hpvc-restore
5+
spec:
6+
storageClassName: csi-hostpath-sc
7+
dataSource:
8+
name: new-snapshot-demo
9+
kind: VolumeSnapshot
10+
apiGroup: snapshot.storage.k8s.io
11+
accessModes:
12+
- ReadWriteOnce
13+
resources:
14+
requests:
15+
storage: 1Gi

examples/kubernetes/snapshot.yaml

+9
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: new-snapshot-demo
5+
spec:
6+
snapshotClassName: csi-hostpath-snapclass
7+
source:
8+
name: hpvc
9+
kind: PersistentVolumeClaim
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: snapshot.storage.k8s.io/v1alpha1
2+
kind: VolumeSnapshotClass
3+
metadata:
4+
name: csi-hostpath-snapclass
5+
snapshotter: csi-hostpath

examples/kubernetes/storageclass.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: storage.k8s.io/v1
2+
kind: StorageClass
3+
metadata:
4+
name: csi-hostpath-sc
5+
provisioner: csi-hostpath
6+
reclaimPolicy: Delete
7+
volumeBindingMode: Immediate

0 commit comments

Comments
 (0)