From 84a4bfba0d3a706212e87b4446d3b48d005346b4 Mon Sep 17 00:00:00 2001 From: clyang82 Date: Wed, 23 Sep 2020 15:15:54 +0800 Subject: [PATCH] separate alertmanager with rules Signed-off-by: clyang82 --- .../kube-thanos/kube-thanos-rule.libsonnet | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet index d9a2f7d5..ab98519d 100644 --- a/jsonnet/kube-thanos/kube-thanos-rule.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-rule.libsonnet @@ -187,8 +187,6 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; withAlertmanagers:: { local tr = self, config+:: { - ruleConfigMapName: error 'must provide ruleConfigMapName', - ruleFileKey: error 'must provide ruleFileKey', alertmanagersURL: error 'must provide alertmanagersURL', }, @@ -201,8 +199,32 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet'; args+: [ '--alertmanagers.url=' + alertmanagerURL, for alertmanagerURL in tr.config.alertmanagersURL - ] + [ - '--rule-file=/etc/thanos/rules/' + tr.config.ruleFileKey, + ], + } else c + for c in super.containers + ], + }, + }, + }, + }, + }, + + withRules:: { + local tr = self, + config+:: { + ruleConfigMapName: error 'must provide ruleConfigMapName', + ruleFilesKey: error 'must provide ruleFilesKey', + }, + + statefulSet+: { + spec+: { + template+: { + spec+: { + containers: [ + if c.name == 'thanos-rule' then c { + args+: [ + '--rule-file=/etc/thanos/rules/' + ruleFileKey, + for ruleFileKey in tr.config.ruleFilesKey ], volumeMounts+: [ { name: 'rules-config', mountPath: '/etc/thanos/rules' },