From 2d5e6ac40860a453bc3740cc2de00f8cad8a53c1 Mon Sep 17 00:00:00 2001 From: clyang82 Date: Wed, 23 Sep 2020 16:52:15 +0800 Subject: [PATCH] Support multiple configmap Signed-off-by: clyang82 --- jsonnet/kube-thanos/kube-thanos-rule.libsonnet | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet index ab98519d..b232ade5 100644 --- a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet @@ -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+: { @@ -223,11 +222,12 @@ 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 @@ -235,8 +235,9 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; 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) ], }, },