Skip to content

Commit 9bbfe57

Browse files
authored
Merge pull request #401 from stevehipwell/helm-volumes
feat(helm): Added support for additional volumes
2 parents a1c19d5 + f507bbb commit 9bbfe57

File tree

6 files changed

+297
-95
lines changed

6 files changed

+297
-95
lines changed

helm/README.md

Lines changed: 56 additions & 52 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
additionalVolumes:
2+
- name: init-config
3+
configMap:
4+
name: init-config
5+
- name: signal
6+
emptyDir: {}
7+
8+
additionalVolumeMounts:
9+
- name: signal
10+
mountPath: /etc/signal
11+
readOnly: true
12+
13+
initContainers:
14+
- name: test
15+
image: alpine:3
16+
command: ["/bin/sh"]
17+
args:
18+
- -c
19+
- /etc/init/run.sh
20+
volumeMounts:
21+
- name: init-config
22+
mountPath: /etc/init
23+
- name: signal
24+
mountPath: /etc/signal
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
# Source: local-static-provisioner/templates/serviceaccount.yaml
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: local-static-provisioner
7+
namespace: default
8+
labels:
9+
helm.sh/chart: local-static-provisioner-1.0.0
10+
app.kubernetes.io/name: local-static-provisioner
11+
app.kubernetes.io/managed-by: Helm
12+
app.kubernetes.io/instance: local-static-provisioner
13+
---
14+
# Source: local-static-provisioner/templates/configmap.yaml
15+
apiVersion: v1
16+
kind: ConfigMap
17+
metadata:
18+
name: local-static-provisioner-config
19+
namespace: default
20+
labels:
21+
helm.sh/chart: local-static-provisioner-1.0.0
22+
app.kubernetes.io/name: local-static-provisioner
23+
app.kubernetes.io/managed-by: Helm
24+
app.kubernetes.io/instance: local-static-provisioner
25+
data:
26+
storageClassMap: |
27+
fast-disks:
28+
hostDir: /mnt/fast-disks
29+
mountDir: /mnt/fast-disks
30+
blockCleanerCommand:
31+
- "/scripts/shred.sh"
32+
- "2"
33+
volumeMode: Filesystem
34+
fsType: ext4
35+
namePattern: "*"
36+
---
37+
# Source: local-static-provisioner/templates/rbac.yaml
38+
apiVersion: rbac.authorization.k8s.io/v1
39+
kind: ClusterRole
40+
metadata:
41+
name: local-static-provisioner-node-clusterrole
42+
labels:
43+
helm.sh/chart: local-static-provisioner-1.0.0
44+
app.kubernetes.io/name: local-static-provisioner
45+
app.kubernetes.io/managed-by: Helm
46+
app.kubernetes.io/instance: local-static-provisioner
47+
rules:
48+
- apiGroups: [""]
49+
resources: ["persistentvolumes"]
50+
verbs: ["get", "list", "watch", "create", "delete"]
51+
- apiGroups: ["storage.k8s.io"]
52+
resources: ["storageclasses"]
53+
verbs: ["get", "list", "watch"]
54+
- apiGroups: [""]
55+
resources: ["events"]
56+
verbs: ["watch"]
57+
- apiGroups: ["", "events.k8s.io"]
58+
resources: ["events"]
59+
verbs: ["create", "update", "patch"]
60+
- apiGroups: [""]
61+
resources: ["nodes"]
62+
verbs: ["get"]
63+
---
64+
# Source: local-static-provisioner/templates/rbac.yaml
65+
apiVersion: rbac.authorization.k8s.io/v1
66+
kind: ClusterRoleBinding
67+
metadata:
68+
name: local-static-provisioner-node-binding
69+
labels:
70+
helm.sh/chart: local-static-provisioner-1.0.0
71+
app.kubernetes.io/name: local-static-provisioner
72+
app.kubernetes.io/managed-by: Helm
73+
app.kubernetes.io/instance: local-static-provisioner
74+
subjects:
75+
- kind: ServiceAccount
76+
name: local-static-provisioner
77+
namespace: default
78+
roleRef:
79+
kind: ClusterRole
80+
name: local-static-provisioner-node-clusterrole
81+
apiGroup: rbac.authorization.k8s.io
82+
---
83+
# Source: local-static-provisioner/templates/daemonset_linux.yaml
84+
apiVersion: apps/v1
85+
kind: DaemonSet
86+
metadata:
87+
name: local-static-provisioner
88+
namespace: default
89+
labels:
90+
helm.sh/chart: local-static-provisioner-1.0.0
91+
app.kubernetes.io/name: local-static-provisioner
92+
app.kubernetes.io/managed-by: Helm
93+
app.kubernetes.io/instance: local-static-provisioner
94+
spec:
95+
selector:
96+
matchLabels:
97+
app.kubernetes.io/name: local-static-provisioner
98+
app.kubernetes.io/instance: local-static-provisioner
99+
template:
100+
metadata:
101+
labels:
102+
app.kubernetes.io/name: local-static-provisioner
103+
app.kubernetes.io/instance: local-static-provisioner
104+
annotations:
105+
checksum/config: fbfc9e88fedc172393c69523b113ad18a015df9a3331a28ebd22fbddf52b4c8e
106+
spec:
107+
serviceAccountName: local-static-provisioner
108+
nodeSelector:
109+
kubernetes.io/os: linux
110+
initContainers:
111+
- args:
112+
- -c
113+
- /etc/init/run.sh
114+
command:
115+
- /bin/sh
116+
image: alpine:3
117+
name: test
118+
volumeMounts:
119+
- mountPath: /etc/init
120+
name: init-config
121+
- mountPath: /etc/signal
122+
name: signal
123+
containers:
124+
- name: provisioner
125+
image: registry.k8s.io/sig-storage/local-volume-provisioner:v2.5.0
126+
securityContext:
127+
privileged: true
128+
env:
129+
- name: MY_NODE_NAME
130+
valueFrom:
131+
fieldRef:
132+
fieldPath: spec.nodeName
133+
- name: MY_NAMESPACE
134+
valueFrom:
135+
fieldRef:
136+
fieldPath: metadata.namespace
137+
- name: JOB_CONTAINER_IMAGE
138+
value: registry.k8s.io/sig-storage/local-volume-provisioner:v2.5.0
139+
ports:
140+
- name: metrics
141+
containerPort: 8080
142+
volumeMounts:
143+
- name: provisioner-config
144+
mountPath: /etc/provisioner/config
145+
readOnly: true
146+
- name: provisioner-dev
147+
mountPath: /dev
148+
- name: fast-disks
149+
mountPath: /mnt/fast-disks
150+
mountPropagation: HostToContainer
151+
- mountPath: /etc/signal
152+
name: signal
153+
readOnly: true
154+
volumes:
155+
- name: provisioner-config
156+
configMap:
157+
name: local-static-provisioner-config
158+
- name: provisioner-dev
159+
hostPath:
160+
path: /dev
161+
- name: fast-disks
162+
hostPath:
163+
path: /mnt/fast-disks
164+
- configMap:
165+
name: init-config
166+
name: init-config
167+
- emptyDir: {}
168+
name: signal

helm/provisioner/templates/daemonset_linux.yaml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,32 @@ spec:
8383
- name: provisioner-config
8484
mountPath: /etc/provisioner/config
8585
readOnly: true
86-
{{- if .Values.mountDevVolume }}
86+
{{- if .Values.mountDevVolume }}
8787
- name: provisioner-dev
8888
mountPath: /dev
89-
{{- end }}
90-
{{- range $classConfig := .Values.classes }}
91-
- name: {{ $classConfig.name }}
92-
mountPath: {{ $classConfig.mountDir | default $classConfig.hostDir }}
89+
{{- end }}
90+
{{- range .Values.classes }}
91+
- name: {{ .name }}
92+
mountPath: {{ default .hostDir .mountDir }}
9393
mountPropagation: HostToContainer
94-
{{- end }}
94+
{{- end }}
95+
{{- with .Values.additionalVolumeMounts }}
96+
{{- toYaml . | nindent 12 }}
97+
{{- end }}
9598
volumes:
9699
- name: provisioner-config
97100
configMap:
98101
name: {{ template "provisioner.fullname" . }}-config
99-
{{- if .Values.mountDevVolume }}
102+
{{- if .Values.mountDevVolume }}
100103
- name: provisioner-dev
101104
hostPath:
102105
path: /dev
103-
{{- end }}
104-
{{- range $classConfig := .Values.classes }}
105-
- name: {{ $classConfig.name }}
106+
{{- end }}
107+
{{- range .Values.classes }}
108+
- name: {{ .name }}
106109
hostPath:
107-
path: {{ $classConfig.hostDir }}
108-
{{- end }}
109-
{{- range $name, $path := .Values.additionalHostPathVolumes }}
110-
- name: {{ quote $name }}
111-
hostPath:
112-
path: {{ quote $path }}
113-
{{- end }}
110+
path: {{ .hostDir }}
111+
{{- end }}
112+
{{- with .Values.additionalVolumes }}
113+
{{- toYaml . | nindent 8 }}
114+
{{- end }}

helm/provisioner/templates/daemonset_windows.yaml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,6 @@ spec:
8585
- name: provisioner-config
8686
mountPath: /etc/provisioner/config
8787
readOnly: true
88-
{{- if .Values.mountDevVolume }}
89-
- name: provisioner-dev
90-
mountPath: /dev
91-
{{- end }}
92-
{{- range $classConfig := .Values.classes }}
93-
- name: {{ $classConfig.name }}
94-
mountPath: {{ $classConfig.mountDir | default $classConfig.hostDir }}
95-
mountPropagation: HostToContainer
96-
{{- end }}
9788
- name: csi-proxy-volume-v1
9889
mountPath: \\.\pipe\csi-proxy-volume-v1
9990
- name: csi-proxy-filesystem-v1
@@ -104,6 +95,18 @@ spec:
10495
mountPath: \\.\pipe\csi-proxy-volume-v1beta2
10596
- name: csi-proxy-filesystem-v1beta2
10697
mountPath: \\.\pipe\csi-proxy-filesystem-v1beta2
98+
{{- if .Values.mountDevVolume }}
99+
- name: provisioner-dev
100+
mountPath: /dev
101+
{{- end }}
102+
{{- range .Values.classes }}
103+
- name: {{ .name }}
104+
mountPath: {{ default .hostDir .mountDir }}
105+
mountPropagation: HostToContainer
106+
{{- end }}
107+
{{- with .Values.additionalVolumeMounts }}
108+
{{- toYaml . | nindent 12 }}
109+
{{- end }}
107110
volumes:
108111
- name: csi-proxy-volume-v1
109112
hostPath:
@@ -126,23 +129,21 @@ spec:
126129
- name: provisioner-config
127130
configMap:
128131
name: {{ template "provisioner.fullname" . }}-config
129-
{{- if .Values.mountDevVolume }}
132+
{{- if .Values.mountDevVolume }}
130133
- name: provisioner-dev
131134
hostPath:
132135
path: "C:\\dev"
133136
# If nothing exists at the given path, an empty directory will be
134137
# created there as needed with permission set to 0755,
135138
# having the same group and ownership with Kubelet.
136139
type: DirectoryOrCreate
137-
{{- end }}
138-
{{- range $classConfig := .Values.classes }}
139-
- name: {{ $classConfig.name }}
140+
{{- end }}
141+
{{- range .Values.classes }}
142+
- name: {{ .name }}
140143
hostPath:
141-
path: {{ $classConfig.hostDir }}
142-
{{- end }}
143-
{{- range $name, $path := .Values.additionalHostPathVolumes }}
144-
- name: {{ quote $name }}
145-
hostPath:
146-
path: {{ quote $path }}
147-
{{- end }}
144+
path: {{ .hostDir }}
145+
{{- end }}
146+
{{- with .Values.additionalVolumes }}
147+
{{- toYaml . | nindent 8 }}
148+
{{- end }}
148149
{{- end }}

helm/provisioner/values.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ useNodeNameOnly: false
2828
# 2*minResyncPeriod. Default: 5m0s.
2929
#minResyncPeriod: 5m0s
3030

31+
# Additional volumes to create, for the default container and init containers
32+
# to consume
33+
additionalVolumes: []
34+
3135
# Mount the host's `/dev/` by default so that block device symlinks can be
3236
# resolved by the containers
3337
mountDevVolume: true
3438

35-
# A mapping of additional HostPath volume names to host paths to create, for
36-
# your init container to consume
37-
additionalHostPathVolumes: {}
38-
# provisioner-proc: /proc
39-
# provisioner-mnt: /mnt
39+
# Additional volumes to mount to the default container, the volumes should
40+
# either be host paths or defined by additionalVolumes
41+
additionalVolumeMounts: []
4042

4143
# Map of label key-value pairs to apply to the PVs created by the
4244
# provisioner. Uncomment to add labels to the list.
@@ -124,7 +126,8 @@ affinity: {}
124126
#
125127
# If configured, resources will set the requests/limits field to the Daemonset PodSpec.
126128
# Ref: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
127-
resources: {}
129+
resources:
130+
{}
128131
# limits:
129132
# memory: "512Mi"
130133
# cpu: "1000m"
@@ -134,6 +137,7 @@ resources: {}
134137
#
135138
# If set to false, containers created by the Provisioner Daemonset will run without extra privileges.
136139
privileged: true
140+
137141
# Any init containers can be configured here.
138142
# Ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
139143
initContainers: []

0 commit comments

Comments
 (0)