Skip to content

Commit 4ea5df6

Browse files
authored
[cinder-csi-plugin] add snapshot controller to Helm Chart (kubernetes#1457)
* [cinder-csi-plugin] add snapshot controller to Helm Chart * fix snapshot controller tag * fix snapshot controller rbac * add comment to snapshot controller installation * remove verbose output
1 parent 4882ed5 commit 4ea5df6

File tree

5 files changed

+135
-1
lines changed

5 files changed

+135
-1
lines changed

charts/cinder-csi-plugin/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
appVersion: latest
33
description: Cinder CSI Chart for OpenStack
44
name: openstack-cinder-csi
5-
version: 1.3.4
5+
version: 1.3.5
66
home: https://github.com/kubernetes/cloud-provider-openstack
77
icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png
88
maintainers:

charts/cinder-csi-plugin/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,13 @@ component: nodeplugin
8888
{{ include "cinder-csi.nodeplugin.matchLabels" . }}
8989
{{ include "cinder-csi.common.metaLabels" . }}
9090
{{- end -}}
91+
92+
{{- define "cinder-csi.snapshot-controller.matchLabels" -}}
93+
component: snapshot-controller
94+
{{ include "cinder-csi.common.matchLabels" . }}
95+
{{- end -}}
96+
97+
{{- define "cinder-csi.snapshot-controller.labels" -}}
98+
{{ include "cinder-csi.snapshot-controller.matchLabels" . }}
99+
{{ include "cinder-csi.common.metaLabels" . }}
100+
{{- end -}}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{{- if .Values.csi.snapshotController.enabled -}}
2+
# RBAC file for the snapshot controller.
3+
#
4+
# The snapshot controller implements the control loop for CSI snapshot functionality.
5+
# It should be installed as part of the base Kubernetes distribution in an appropriate
6+
# namespace for components implementing base system functionality. For installing with
7+
# Vanilla Kubernetes, kube-system makes sense for the namespace.
8+
#
9+
# Enable this only if your Kubernetes distribution does not bundle the snapshot controller.
10+
# It should be installed only once per cluster, independent of CSI driver.
11+
12+
apiVersion: v1
13+
kind: ServiceAccount
14+
metadata:
15+
name: snapshot-controller
16+
namespace: {{ .Release.Namespace }}
17+
---
18+
kind: ClusterRole
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
metadata:
21+
name: snapshot-controller-runner
22+
rules:
23+
- apiGroups: [""]
24+
resources: ["persistentvolumes"]
25+
verbs: ["get", "list", "watch"]
26+
- apiGroups: [""]
27+
resources: ["persistentvolumeclaims"]
28+
verbs: ["get", "list", "watch", "update"]
29+
- apiGroups: ["storage.k8s.io"]
30+
resources: ["storageclasses"]
31+
verbs: ["get", "list", "watch"]
32+
- apiGroups: [""]
33+
resources: ["events"]
34+
verbs: ["list", "watch", "create", "update", "patch"]
35+
- apiGroups: ["snapshot.storage.k8s.io"]
36+
resources: ["volumesnapshotclasses"]
37+
verbs: ["get", "list", "watch"]
38+
- apiGroups: ["snapshot.storage.k8s.io"]
39+
resources: ["volumesnapshotcontents"]
40+
verbs: ["create", "get", "list", "watch", "update", "delete"]
41+
- apiGroups: ["snapshot.storage.k8s.io"]
42+
resources: ["volumesnapshots"]
43+
verbs: ["get", "list", "watch", "update"]
44+
- apiGroups: ["snapshot.storage.k8s.io"]
45+
resources: ["volumesnapshots/status"]
46+
verbs: ["update"]
47+
---
48+
kind: ClusterRoleBinding
49+
apiVersion: rbac.authorization.k8s.io/v1
50+
metadata:
51+
name: snapshot-controller-role
52+
subjects:
53+
- kind: ServiceAccount
54+
name: snapshot-controller-sa
55+
namespace: {{ .Release.Namespace }}
56+
roleRef:
57+
kind: ClusterRole
58+
# change the name also here if the ClusterRole gets renamed
59+
name: snapshot-controller-runner
60+
apiGroup: rbac.authorization.k8s.io
61+
---
62+
kind: Role
63+
apiVersion: rbac.authorization.k8s.io/v1
64+
metadata:
65+
name: snapshot-controller-leaderelection
66+
namespace: {{ .Release.Namespace }}
67+
rules:
68+
- apiGroups: ["coordination.k8s.io"]
69+
resources: ["leases"]
70+
verbs: ["get", "watch", "list", "delete", "update", "create"]
71+
---
72+
kind: RoleBinding
73+
apiVersion: rbac.authorization.k8s.io/v1
74+
metadata:
75+
name: snapshot-controller-leaderelection
76+
namespace: {{ .Release.Namespace }}
77+
subjects:
78+
- kind: ServiceAccount
79+
name: snapshot-controller
80+
namespace: {{ .Release.Namespace }}
81+
roleRef:
82+
kind: Role
83+
name: snapshot-controller-leaderelection
84+
apiGroup: rbac.authorization.k8s.io
85+
{{- end }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{- if .Values.csi.snapshotController.enabled -}}
2+
# This YAML file shows how to deploy the snapshot controller
3+
4+
# The snapshot controller implements the control loop for CSI snapshot functionality.
5+
# It should be installed as part of the base Kubernetes distribution in an appropriate
6+
# namespace for components implementing base system functionality. For installing with
7+
# Vanilla Kubernetes, kube-system makes sense for the namespace.
8+
9+
---
10+
kind: StatefulSet
11+
apiVersion: apps/v1
12+
metadata:
13+
labels:
14+
{{- include "cinder-csi.snapshot-controller.labels" . | nindent 4 }}
15+
name: {{ include "cinder-csi.name" . }}-snapshot-controller
16+
spec:
17+
serviceName: "snapshot-controller"
18+
replicas: 1
19+
selector:
20+
matchLabels:
21+
{{- include "cinder-csi.snapshot-controller.matchLabels" . | nindent 6 }}
22+
template:
23+
metadata:
24+
labels:
25+
{{- include "cinder-csi.snapshot-controller.labels" . | nindent 8 }}
26+
spec:
27+
serviceAccount: snapshot-controller-sa
28+
containers:
29+
- name: snapshot-controller
30+
image: "{{ .Values.csi.snapshotController.image.repository }}:{{ .Values.csi.snapshotController.image.tag }}"
31+
args:
32+
- "--leader-election=false"
33+
imagePullPolicy: IfNotPresent
34+
{{- end }}

charts/cinder-csi-plugin/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ csi:
5454
- name: cloud-config
5555
mountPath: /etc/kubernetes
5656
readOnly: true
57+
snapshotController:
58+
enabled: false
59+
image:
60+
repository: k8s.gcr.io/sig-storage/snapshot-controller
61+
tag: v2.1.3
5762

5863
secret:
5964
enabled: false

0 commit comments

Comments
 (0)