Skip to content

Commit 2d5e6ac

Browse files
committed
Support multiple configmap
Signed-off-by: clyang82 <[email protected]>
1 parent 84a4bfb commit 2d5e6ac

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

jsonnet/kube-thanos/kube-thanos-rule.libsonnet

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
212212
withRules:: {
213213
local tr = self,
214214
config+:: {
215-
ruleConfigMapName: error 'must provide ruleConfigMapName',
216-
ruleFilesKey: error 'must provide ruleFilesKey',
215+
rulesConfig: error 'must provide rulesConfig',
217216
},
218217

219218
statefulSet+: {
@@ -223,20 +222,22 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
223222
containers: [
224223
if c.name == 'thanos-rule' then c {
225224
args+: [
226-
'--rule-file=/etc/thanos/rules/' + ruleFileKey,
227-
for ruleFileKey in tr.config.ruleFilesKey
225+
'--rule-file=/etc/thanos/rules/' + ruleConfig.name + '/' + ruleConfig.key,
226+
for ruleConfig in std.objectFields(tr.config.rulesConfig)
228227
],
229228
volumeMounts+: [
230-
{ name: 'rules-config', mountPath: '/etc/thanos/rules' },
229+
{ name: ruleConfig.name, mountPath: '/etc/thanos/rules/' + ruleConfig.name },
230+
for ruleConfig in std.objectFields(tr.config.rulesConfig)
231231
],
232232
} else c
233233
for c in super.containers
234234
],
235235

236236
local volume = k.apps.v1.statefulSet.mixin.spec.template.spec.volumesType,
237237
volumes+: [
238-
volume.withName('rules-config') +
239-
volume.mixin.configMap.withName(tr.config.ruleConfigMapName),
238+
volume.withName(ruleConfig.name) +
239+
volume.mixin.configMap.withName(ruleConfig.name),
240+
for ruleConfig in std.objectFields(tr.config.rulesConfig)
240241
],
241242
},
242243
},

0 commit comments

Comments
 (0)