Skip to content

Commit

Permalink
Merge pull request #263 from saswatamcode/add-stateless-ruler
Browse files Browse the repository at this point in the history
Support stateless Ruler
  • Loading branch information
yeya24 authored Feb 8, 2022
2 parents 55d79c6 + e401391 commit 336482e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Added

- [#263](https://github.com/thanos-io/kube-thanos/pull/263) Add support for stateless Rulers.

### Fixed

-
Expand Down
4 changes: 4 additions & 0 deletions all.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ local ru = t.rule(commonConfig {
name: 'thanos-ruler-config',
key: 'config.yaml',
},
remoteWriteConfigFile: {
name: 'thanos-stateless-ruler-config',
key: 'rw-config.yaml',
},
reloaderImage: 'jimmidyson/configmap-reload:v0.5.0',
serviceMonitor: true,
});
Expand Down
10 changes: 10 additions & 0 deletions examples/all/manifests/thanos-rule-statefulSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ spec:
"sampler_type": "ratelimiting"
"service_name": "thanos-rule"
"type": "JAEGER"
- --remote-write.config-file=/etc/thanos/config/thanos-stateless-ruler-config/rw-config.yaml
env:
- name: NAME
valueFrom:
Expand Down Expand Up @@ -103,10 +104,14 @@ spec:
- mountPath: /etc/thanos/config/thanos-ruler-config
name: thanos-ruler-config
readOnly: true
- mountPath: /etc/thanos/config/thanos-stateless-ruler-config
name: thanos-stateless-ruler-config
readOnly: true
- args:
- -webhook-url=http://localhost:10902/-/reload
- -volume-dir=/etc/thanos/rules/test
- -volume-dir=/etc/thanos/config/thanos-ruler-config
- -volume-dir=/etc/thanos/config/thanos-stateless-ruler-config
image: jimmidyson/configmap-reload:v0.5.0
imagePullPolicy: IfNotPresent
name: configmap-reloader
Expand All @@ -115,6 +120,8 @@ spec:
name: test
- mountPath: /etc/thanos/config/thanos-ruler-config
name: thanos-ruler-config
- mountPath: /etc/thanos/config/thanos-stateless-ruler-config
name: thanos-stateless-ruler-config
nodeSelector:
kubernetes.io/os: linux
securityContext:
Expand All @@ -128,6 +135,9 @@ spec:
- configMap:
name: thanos-ruler-config
name: thanos-ruler-config
- configMap:
name: thanos-stateless-ruler-config
name: thanos-stateless-ruler-config
volumeClaimTemplates:
- metadata:
labels:
Expand Down
26 changes: 25 additions & 1 deletion jsonnet/kube-thanos/kube-thanos-rule.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local defaults = {
objectStorageConfig: error 'must provide objectStorageConfig',
ruleFiles: [],
rulesConfig: [],
remoteWriteConfigFile: {},
alertmanagersURLs: [],
alertmanagerConfigFile: {},
extraVolumeMounts: [],
Expand Down Expand Up @@ -60,6 +61,7 @@ function(params) {
assert std.isNumber(tr.config.replicas) && tr.config.replicas >= 0 : 'thanos rule replicas has to be number >= 0',
assert std.isArray(tr.config.ruleFiles),
assert std.isArray(tr.config.rulesConfig),
assert std.isObject(tr.config.remoteWriteConfigFile),
assert std.isArray(tr.config.alertmanagersURLs),
assert std.isObject(tr.config.alertmanagerConfigFile),
assert std.isArray(tr.config.extraVolumeMounts),
Expand Down Expand Up @@ -143,6 +145,11 @@ function(params) {
{ config+: { service_name: defaults.name } } + tr.config.tracing
),
] else []
) + (
if tr.config.remoteWriteConfigFile != {} then [
'--remote-write.config-file=/etc/thanos/config/' + tr.config.remoteWriteConfigFile.name + '/' + tr.config.remoteWriteConfigFile.key,
]
else []
),
env: [
{ name: 'NAME', valueFrom: { fieldRef: { fieldPath: 'metadata.name' } } },
Expand Down Expand Up @@ -188,6 +195,10 @@ function(params) {
if tr.config.objectStorageConfig != null && std.objectHas(tr.config.objectStorageConfig, 'tlsSecretName') && std.length(tr.config.objectStorageConfig.tlsSecretName) > 0 then [
{ name: 'tls-secret', mountPath: tr.config.objectStorageConfig.tlsSecretMountPath },
] else []
) + (
if tr.config.remoteWriteConfigFile != {} then [
{ name: tr.config.remoteWriteConfigFile.name, mountPath: '/etc/thanos/config/' + tr.config.remoteWriteConfigFile.name, readOnly: true },
] else []
),
livenessProbe: { failureThreshold: 24, periodSeconds: 5, httpGet: {
scheme: 'HTTP',
Expand Down Expand Up @@ -226,6 +237,10 @@ function(params) {
'-volume-dir=' + volumeMount.mountPath
for volumeMount in tr.config.extraVolumeMounts
] else []
) + (
if tr.config.remoteWriteConfigFile != {} then [
'-volume-dir=/etc/thanos/config/' + tr.config.remoteWriteConfigFile.name,
] else []
),
volumeMounts: [
{ name: ruleConfig.name, mountPath: '/etc/thanos/rules/' + ruleConfig.name }
Expand All @@ -239,6 +254,10 @@ function(params) {
{ name: volumeMount.name, mountPath: volumeMount.mountPath }
for volumeMount in tr.config.extraVolumeMounts
] else []
) + (
if tr.config.remoteWriteConfigFile != {} then [
{ name: tr.config.remoteWriteConfigFile.name, mountPath: '/etc/thanos/config/' + tr.config.remoteWriteConfigFile.name },
] else []
),
};

Expand All @@ -263,7 +282,7 @@ function(params) {
securityContext: tr.config.securityContext,
containers: [c] +
(
if std.length(tr.config.rulesConfig) > 0 || std.length(tr.config.extraVolumeMounts) > 0 || tr.config.alertmanagerConfigFile != {} then [
if std.length(tr.config.rulesConfig) > 0 || std.length(tr.config.extraVolumeMounts) > 0 || tr.config.alertmanagerConfigFile != {} || tr.config.remoteWriteConfigFile != {} then [
reloadContainer,
] else []
),
Expand All @@ -279,6 +298,11 @@ function(params) {
name: tr.config.alertmanagerConfigFile.name,
configMap: { name: tr.config.alertmanagerConfigFile.name },
}] else []
) + (
if tr.config.remoteWriteConfigFile != {} then [{
name: tr.config.remoteWriteConfigFile.name,
configMap: { name: tr.config.remoteWriteConfigFile.name },
}] else []
) + (
if std.length(tr.config.extraVolumeMounts) > 0 then [
{ name: volumeMount.name } +
Expand Down

0 comments on commit 336482e

Please sign in to comment.