Skip to content

Commit

Permalink
Support multiple configmap
Browse files Browse the repository at this point in the history
Signed-off-by: clyang82 <[email protected]>
  • Loading branch information
clyang82 committed Sep 23, 2020
1 parent 84a4bfb commit 2d5e6ac
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions jsonnet/kube-thanos/kube-thanos-rule.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
withRules:: {
local tr = self,
config+:: {
ruleConfigMapName: error 'must provide ruleConfigMapName',
ruleFilesKey: error 'must provide ruleFilesKey',
rulesConfig: error 'must provide rulesConfig',
},

statefulSet+: {
Expand All @@ -223,20 +222,22 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
containers: [
if c.name == 'thanos-rule' then c {
args+: [
'--rule-file=/etc/thanos/rules/' + ruleFileKey,
for ruleFileKey in tr.config.ruleFilesKey
'--rule-file=/etc/thanos/rules/' + ruleConfig.name + '/' + ruleConfig.key,
for ruleConfig in std.objectFields(tr.config.rulesConfig)
],
volumeMounts+: [
{ name: 'rules-config', mountPath: '/etc/thanos/rules' },
{ name: ruleConfig.name, mountPath: '/etc/thanos/rules/' + ruleConfig.name },
for ruleConfig in std.objectFields(tr.config.rulesConfig)
],
} else c
for c in super.containers
],

local volume = k.apps.v1.statefulSet.mixin.spec.template.spec.volumesType,
volumes+: [
volume.withName('rules-config') +
volume.mixin.configMap.withName(tr.config.ruleConfigMapName),
volume.withName(ruleConfig.name) +
volume.mixin.configMap.withName(ruleConfig.name),
for ruleConfig in std.objectFields(tr.config.rulesConfig)
],
},
},
Expand Down

0 comments on commit 2d5e6ac

Please sign in to comment.