|
| 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: ["create", "get", "list", "watch", "update", "delete"] |
| 47 | + - apiGroups: ["snapshot.storage.k8s.io"] |
| 48 | + resources: ["volumesnapshots/status"] |
| 49 | + verbs: ["update"] |
| 50 | + - apiGroups: ["apiextensions.k8s.io"] |
| 51 | + resources: ["customresourcedefinitions"] |
| 52 | + verbs: ["create", "list", "watch", "delete"] |
| 53 | + |
| 54 | +--- |
| 55 | +kind: ClusterRoleBinding |
| 56 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 57 | +metadata: |
| 58 | + name: csi-snapshotter-role |
| 59 | +subjects: |
| 60 | + - kind: ServiceAccount |
| 61 | + name: csi-snapshotter |
| 62 | + namespace: default |
| 63 | +roleRef: |
| 64 | + kind: ClusterRole |
| 65 | + name: external-snapshotter-runner |
| 66 | + apiGroup: rbac.authorization.k8s.io |
| 67 | + |
| 68 | +--- |
| 69 | +kind: Service |
| 70 | +apiVersion: v1 |
| 71 | +metadata: |
| 72 | + name: csi-snapshotter |
| 73 | + labels: |
| 74 | + app: csi-snapshotter |
| 75 | +spec: |
| 76 | + selector: |
| 77 | + app: csi-snapshotter |
| 78 | + ports: |
| 79 | + - name: dummy |
| 80 | + port: 12345 |
| 81 | + |
| 82 | +--- |
| 83 | +kind: StatefulSet |
| 84 | +apiVersion: apps/v1 |
| 85 | +metadata: |
| 86 | + name: csi-snapshotter |
| 87 | +spec: |
| 88 | + serviceName: "csi-snapshotter" |
| 89 | + replicas: 1 |
| 90 | + selector: |
| 91 | + matchLabels: |
| 92 | + app: csi-snapshotter |
| 93 | + template: |
| 94 | + metadata: |
| 95 | + labels: |
| 96 | + app: csi-snapshotter |
| 97 | + spec: |
| 98 | + serviceAccount: csi-snapshotter |
| 99 | + containers: |
| 100 | + - name: csi-provisioner |
| 101 | + image: xyang105/csi:csi-provisioner |
| 102 | + args: |
| 103 | + - "--provisioner=csi-hostpath" |
| 104 | + - "--csi-address=$(ADDRESS)" |
| 105 | + - "--connection-timeout=15s" |
| 106 | + env: |
| 107 | + - name: ADDRESS |
| 108 | + value: /csi/csi.sock |
| 109 | + imagePullPolicy: "IfNotPresent" |
| 110 | + volumeMounts: |
| 111 | + - name: socket-dir |
| 112 | + mountPath: /csi |
| 113 | + - name: csi-snapshotter |
| 114 | + image: xyang105/csi:csi-snapshotter |
| 115 | + args: |
| 116 | + - "--snapshotter=csi-hostpath" |
| 117 | + - "--csi-address=$(ADDRESS)" |
| 118 | + - "--connection-timeout=15s" |
| 119 | + env: |
| 120 | + - name: ADDRESS |
| 121 | + value: /csi/csi.sock |
| 122 | + imagePullPolicy: "IfNotPresent" |
| 123 | + volumeMounts: |
| 124 | + - name: socket-dir |
| 125 | + mountPath: /csi |
| 126 | + - name: hostpath |
| 127 | + image: xyang105/csi:csi-hostpath |
| 128 | + args: |
| 129 | + - "--v=5" |
| 130 | + - "--endpoint=$(CSI_ENDPOINT)" |
| 131 | + - "--nodeid=$(KUBE_NODE_NAME)" |
| 132 | + env: |
| 133 | + - name: CSI_ENDPOINT |
| 134 | + value: unix:///csi/csi.sock |
| 135 | + - name: KUBE_NODE_NAME |
| 136 | + valueFrom: |
| 137 | + fieldRef: |
| 138 | + apiVersion: v1 |
| 139 | + fieldPath: spec.nodeName |
| 140 | + imagePullPolicy: IfNotPresent |
| 141 | + securityContext: |
| 142 | + privileged: true |
| 143 | + volumeMounts: |
| 144 | + - name: socket-dir |
| 145 | + mountPath: /csi |
| 146 | + volumes: |
| 147 | + - name: socket-dir |
| 148 | + emptyDir: |
0 commit comments