Skip to content

Commit 72946fa

Browse files
committed
[helm] Add extraVolumes, extraVolumeMounts, initContainers
1 parent 183685c commit 72946fa

5 files changed

Lines changed: 408 additions & 0 deletions

File tree

helm/templates/sts-coordinator.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ spec:
3939
serviceAccountName: {{ .Values.serviceAccount.name | default (include "fluss.fullname" .) }}
4040
{{- end }}
4141
{{- include "fluss.imagePullSecrets" . | nindent 6 }}
42+
{{- with .Values.coordinator.initContainers }}
43+
initContainers:
44+
{{- toYaml . | nindent 8 }}
45+
{{- end }}
4246
containers:
4347
- name: {{ .Chart.Name }}-coordinator
4448
image: {{ include "fluss.image" . }}
@@ -110,6 +114,9 @@ spec:
110114
mountPath: /etc/fluss/conf
111115
readOnly: true
112116
{{- end }}
117+
{{- with .Values.coordinator.extraVolumeMounts }}
118+
{{- toYaml . | nindent 12 }}
119+
{{- end }}
113120
volumes:
114121
- name: fluss-conf
115122
configMap:
@@ -123,6 +130,9 @@ spec:
123130
secret:
124131
secretName: {{ include "fluss.security.jaas.configName" . }}
125132
{{- end }}
133+
{{- with .Values.coordinator.extraVolumes }}
134+
{{- toYaml . | nindent 8 }}
135+
{{- end }}
126136
{{- if .Values.coordinator.storage.enabled }}
127137
volumeClaimTemplates:
128138
- metadata:

helm/templates/sts-tablet.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ spec:
3939
serviceAccountName: {{ .Values.serviceAccount.name | default (include "fluss.fullname" .) }}
4040
{{- end }}
4141
{{- include "fluss.imagePullSecrets" . | nindent 6 }}
42+
{{- with .Values.tablet.initContainers }}
43+
initContainers:
44+
{{- toYaml . | nindent 8 }}
45+
{{- end }}
4246
containers:
4347
- name: {{ .Chart.Name }}-tablet
4448
image: {{ include "fluss.image" . }}
@@ -107,6 +111,9 @@ spec:
107111
mountPath: /etc/fluss/conf
108112
readOnly: true
109113
{{- end }}
114+
{{- with .Values.tablet.extraVolumeMounts }}
115+
{{- toYaml . | nindent 12 }}
116+
{{- end }}
110117
volumes:
111118
- name: fluss-conf
112119
configMap:
@@ -120,6 +127,9 @@ spec:
120127
secret:
121128
secretName: {{ include "fluss.security.jaas.configName" . }}
122129
{{- end }}
130+
{{- with .Values.tablet.extraVolumes }}
131+
{{- toYaml . | nindent 8 }}
132+
{{- end }}
123133
{{- if .Values.tablet.storage.enabled }}
124134
volumeClaimTemplates:
125135
- metadata:

helm/tests/extra_volumes_test.yaml

Lines changed: 333 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,333 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
suite: defaults
20+
templates:
21+
- templates/sts-coordinator.yaml
22+
- templates/sts-tablet.yaml
23+
24+
tests:
25+
- it: should not render initContainers by default on coordinator
26+
asserts:
27+
- isNull:
28+
path: spec.template.spec.initContainers
29+
template: templates/sts-coordinator.yaml
30+
31+
- it: should not render initContainers by default on tablet
32+
asserts:
33+
- isNull:
34+
path: spec.template.spec.initContainers
35+
template: templates/sts-tablet.yaml
36+
37+
- it: should not render extra volumeMounts beyond built-ins by default on coordinator
38+
asserts:
39+
- equal:
40+
path: spec.template.spec.containers[0].volumeMounts
41+
value:
42+
- name: fluss-conf
43+
mountPath: /opt/conf
44+
- name: data
45+
mountPath: /tmp/fluss/data
46+
template: templates/sts-coordinator.yaml
47+
48+
- it: should not render extra volumeMounts beyond built-ins by default on tablet
49+
asserts:
50+
- equal:
51+
path: spec.template.spec.containers[0].volumeMounts
52+
value:
53+
- name: fluss-conf
54+
mountPath: /opt/conf
55+
- name: data
56+
mountPath: /tmp/fluss/data
57+
template: templates/sts-tablet.yaml
58+
59+
---
60+
61+
suite: coordinator extra resources
62+
templates:
63+
- templates/sts-coordinator.yaml
64+
65+
tests:
66+
- it: should render initContainers on coordinator
67+
set:
68+
coordinator.initContainers:
69+
- name: init-wait
70+
image: busybox:latest
71+
command: ["sh", "-c", "echo ready"]
72+
asserts:
73+
- contains:
74+
path: spec.template.spec.initContainers
75+
content:
76+
name: init-wait
77+
image: busybox:latest
78+
command: ["sh", "-c", "echo ready"]
79+
80+
- it: should render multiple initContainers on coordinator
81+
set:
82+
coordinator.initContainers:
83+
- name: init-one
84+
image: busybox:latest
85+
command: ["sh", "-c", "echo one"]
86+
- name: init-two
87+
image: busybox:latest
88+
command: ["sh", "-c", "echo two"]
89+
asserts:
90+
- contains:
91+
path: spec.template.spec.initContainers
92+
content:
93+
name: init-one
94+
image: busybox:latest
95+
command: ["sh", "-c", "echo one"]
96+
- contains:
97+
path: spec.template.spec.initContainers
98+
content:
99+
name: init-two
100+
image: busybox:latest
101+
command: ["sh", "-c", "echo two"]
102+
103+
- it: should render extraVolumes on coordinator
104+
set:
105+
coordinator.extraVolumes:
106+
- name: custom-config
107+
configMap:
108+
name: my-config
109+
asserts:
110+
- contains:
111+
path: spec.template.spec.volumes
112+
content:
113+
name: custom-config
114+
configMap:
115+
name: my-config
116+
117+
- it: should render extraVolumeMounts on coordinator
118+
set:
119+
coordinator.extraVolumeMounts:
120+
- name: custom-config
121+
mountPath: /custom
122+
asserts:
123+
- contains:
124+
path: spec.template.spec.containers[0].volumeMounts
125+
content:
126+
name: custom-config
127+
mountPath: /custom
128+
129+
- it: should not apply tablet extra resources to coordinator
130+
set:
131+
tablet.extraVolumes:
132+
- name: tablet-only
133+
emptyDir: {}
134+
tablet.extraVolumeMounts:
135+
- name: tablet-only
136+
mountPath: /tablet
137+
tablet.initContainers:
138+
- name: tablet-init
139+
image: busybox:latest
140+
asserts:
141+
- isNull:
142+
path: spec.template.spec.initContainers
143+
- notContains:
144+
path: spec.template.spec.volumes
145+
content:
146+
name: tablet-only
147+
any: true
148+
- notContains:
149+
path: spec.template.spec.containers[0].volumeMounts
150+
content:
151+
name: tablet-only
152+
any: true
153+
154+
---
155+
156+
suite: tablet extra resources
157+
templates:
158+
- templates/sts-tablet.yaml
159+
160+
tests:
161+
- it: should render initContainers on tablet
162+
set:
163+
tablet.initContainers:
164+
- name: init-wait
165+
image: busybox:latest
166+
command: ["sh", "-c", "echo ready"]
167+
asserts:
168+
- contains:
169+
path: spec.template.spec.initContainers
170+
content:
171+
name: init-wait
172+
image: busybox:latest
173+
command: ["sh", "-c", "echo ready"]
174+
175+
- it: should render multiple initContainers on tablet
176+
set:
177+
tablet.initContainers:
178+
- name: init-one
179+
image: busybox:latest
180+
command: ["sh", "-c", "echo one"]
181+
- name: init-two
182+
image: busybox:latest
183+
command: ["sh", "-c", "echo two"]
184+
asserts:
185+
- contains:
186+
path: spec.template.spec.initContainers
187+
content:
188+
name: init-one
189+
image: busybox:latest
190+
command: ["sh", "-c", "echo one"]
191+
- contains:
192+
path: spec.template.spec.initContainers
193+
content:
194+
name: init-two
195+
image: busybox:latest
196+
command: ["sh", "-c", "echo two"]
197+
198+
- it: should render extraVolumes on tablet
199+
set:
200+
tablet.extraVolumes:
201+
- name: custom-config
202+
configMap:
203+
name: my-config
204+
asserts:
205+
- contains:
206+
path: spec.template.spec.volumes
207+
content:
208+
name: custom-config
209+
configMap:
210+
name: my-config
211+
212+
- it: should render extraVolumeMounts on tablet
213+
set:
214+
tablet.extraVolumeMounts:
215+
- name: custom-config
216+
mountPath: /custom
217+
asserts:
218+
- contains:
219+
path: spec.template.spec.containers[0].volumeMounts
220+
content:
221+
name: custom-config
222+
mountPath: /custom
223+
224+
- it: should not apply coordinator extra resources to tablet
225+
set:
226+
coordinator.extraVolumes:
227+
- name: coordinator-only
228+
emptyDir: {}
229+
coordinator.extraVolumeMounts:
230+
- name: coordinator-only
231+
mountPath: /coordinator
232+
coordinator.initContainers:
233+
- name: coordinator-init
234+
image: busybox:latest
235+
asserts:
236+
- isNull:
237+
path: spec.template.spec.initContainers
238+
- notContains:
239+
path: spec.template.spec.volumes
240+
content:
241+
name: coordinator-only
242+
any: true
243+
- notContains:
244+
path: spec.template.spec.containers[0].volumeMounts
245+
content:
246+
name: coordinator-only
247+
any: true
248+
249+
---
250+
251+
suite: coexistence with existing resources
252+
templates:
253+
- templates/sts-coordinator.yaml
254+
- templates/sts-tablet.yaml
255+
256+
tests:
257+
- it: should preserve built-in volumes when extraVolumes are added on coordinator
258+
set:
259+
coordinator.extraVolumes:
260+
- name: extra-vol
261+
emptyDir: {}
262+
asserts:
263+
- contains:
264+
path: spec.template.spec.volumes
265+
content:
266+
name: fluss-conf
267+
configMap:
268+
name: fluss-conf-file
269+
template: templates/sts-coordinator.yaml
270+
- contains:
271+
path: spec.template.spec.volumes
272+
content:
273+
name: extra-vol
274+
emptyDir: {}
275+
template: templates/sts-coordinator.yaml
276+
277+
- it: should preserve built-in volumes when extraVolumes are added on tablet
278+
set:
279+
tablet.extraVolumes:
280+
- name: extra-vol
281+
emptyDir: {}
282+
asserts:
283+
- contains:
284+
path: spec.template.spec.volumes
285+
content:
286+
name: fluss-conf
287+
configMap:
288+
name: fluss-conf-file
289+
template: templates/sts-tablet.yaml
290+
- contains:
291+
path: spec.template.spec.volumes
292+
content:
293+
name: extra-vol
294+
emptyDir: {}
295+
template: templates/sts-tablet.yaml
296+
297+
- it: should preserve built-in volumeMounts when extraVolumeMounts are added on coordinator
298+
set:
299+
coordinator.extraVolumeMounts:
300+
- name: extra-vol
301+
mountPath: /extra
302+
asserts:
303+
- contains:
304+
path: spec.template.spec.containers[0].volumeMounts
305+
content:
306+
name: fluss-conf
307+
mountPath: /opt/conf
308+
template: templates/sts-coordinator.yaml
309+
- contains:
310+
path: spec.template.spec.containers[0].volumeMounts
311+
content:
312+
name: extra-vol
313+
mountPath: /extra
314+
template: templates/sts-coordinator.yaml
315+
316+
- it: should preserve built-in volumeMounts when extraVolumeMounts are added on tablet
317+
set:
318+
tablet.extraVolumeMounts:
319+
- name: extra-vol
320+
mountPath: /extra
321+
asserts:
322+
- contains:
323+
path: spec.template.spec.containers[0].volumeMounts
324+
content:
325+
name: fluss-conf
326+
mountPath: /opt/conf
327+
template: templates/sts-tablet.yaml
328+
- contains:
329+
path: spec.template.spec.containers[0].volumeMounts
330+
content:
331+
name: extra-vol
332+
mountPath: /extra
333+
template: templates/sts-tablet.yaml

0 commit comments

Comments
 (0)