Skip to content

Commit

Permalink
Support scraping config-reloader sidecar for Thanos Ruler
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Gough <philip.p.gough@gmail.com>
  • Loading branch information
philipgough committed Sep 2, 2021
1 parent cfd8d78 commit db7ac2d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
3 changes: 3 additions & 0 deletions examples/all/manifests/thanos-rule-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ spec:
- name: http
port: 10902
targetPort: 10902
- name: reloader
port: 8080
targetPort: 8080
selector:
app.kubernetes.io/component: rule-evaluation-engine
app.kubernetes.io/instance: thanos-rule
Expand Down
1 change: 1 addition & 0 deletions examples/all/manifests/thanos-rule-serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
- namespace
- pod
targetLabel: instance
- port: reloader
selector:
matchLabels:
app.kubernetes.io/component: rule-evaluation-engine
Expand Down
1 change: 1 addition & 0 deletions examples/all/manifests/thanos-rule-statefulSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ spec:
- args:
- -webhook-url=http://localhost:10902/-/reload
- -volume-dir=/etc/thanos/rules/test
- -listen-address=:8080
image: jimmidyson/configmap-reload:v0.5.0
name: configmap-reloader
volumeMounts:
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module kube-thanos

go 1.16
55 changes: 36 additions & 19 deletions jsonnet/kube-thanos/kube-thanos-rule.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ local defaults = {
http: 10902,
},
tracing: {},
scrapeConfigReloader: true,
reloaderPort: 8080,

commonLabels:: {
'app.kubernetes.io/name': 'thanos-rule',
Expand Down Expand Up @@ -71,16 +73,21 @@ function(params) {
},
spec: {
ports: [
{
assert std.isString(name),
assert std.isNumber(tr.config.ports[name]),
{
assert std.isString(name),
assert std.isNumber(tr.config.ports[name]),

name: name,
port: tr.config.ports[name],
targetPort: tr.config.ports[name],
}
for name in std.objectFields(tr.config.ports)
],
name: name,
port: tr.config.ports[name],
targetPort: tr.config.ports[name],
}
for name in std.objectFields(tr.config.ports)
] +
(
if tr.config.scrapeConfigReloader == true then
[{ name: 'reloader', port: tr.config.reloaderPort, targetPort: tr.config.reloaderPort }]
else []
),
clusterIP: 'None',
selector: tr.config.podLabelSelector,
},
Expand Down Expand Up @@ -182,7 +189,12 @@ function(params) {
[
'-webhook-url=http://localhost:' + tr.service.spec.ports[1].port + '/-/reload',
] +
(['-volume-dir=/etc/thanos/rules/' + ruleConfig.name for ruleConfig in tr.config.rulesConfig]),
(['-volume-dir=/etc/thanos/rules/' + ruleConfig.name for ruleConfig in tr.config.rulesConfig]) +
(
if tr.config.scrapeConfigReloader then [
'-listen-address=:' + tr.config.reloaderPort,
] else []
),
volumeMounts: [
{ name: ruleConfig.name, mountPath: '/etc/thanos/rules/' + ruleConfig.name }
for ruleConfig in tr.config.rulesConfig
Expand Down Expand Up @@ -241,15 +253,20 @@ function(params) {
matchLabels: tr.config.podLabelSelector,
},
endpoints: [
{
port: 'http',
relabelings: [{
sourceLabels: ['namespace', 'pod'],
separator: '/',
targetLabel: 'instance',
}],
},
],
{
port: 'http',
relabelings: [{
sourceLabels: ['namespace', 'pod'],
separator: '/',
targetLabel: 'instance',
}],
},
] +
(
if tr.config.scrapeConfigReloader == true then
[{ port: 'reloader' }]
else []
),
},
},
}

0 comments on commit db7ac2d

Please sign in to comment.