Skip to content

Support stateless Ruler #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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