Skip to content
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

fix(thanos) Enable standalone thanos query deployment #567

Merged
merged 13 commits into from
Feb 5, 2025
2 changes: 2 additions & 0 deletions thanos/charts/templates/compactor-svc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if and .Values.thanos.compactor.enabled (not .Values.thanos.query.standalone) }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -24,3 +25,4 @@ spec:
selector:
app.kubernetes.io/managed-by: {{ include "release.name" . }}
app.kubernetes.io/name: compactor
{{ end }}
2 changes: 1 addition & 1 deletion thanos/charts/templates/compactor.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if .Values.thanos.compactor.enabled }}
{{ if and .Values.thanos.compactor.enabled (not .Values.thanos.query.standalone) }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
2 changes: 2 additions & 0 deletions thanos/charts/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if and .Values.thanos.compactor.enabled (not .Values.thanos.query.standalone) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand All @@ -21,3 +22,4 @@ spec:
resources:
requests:
storage: {{ default "100Gi" .Values.thanos.compactor.volume.size }}
{{ end }}
2 changes: 1 addition & 1 deletion thanos/charts/templates/ruler/alertmanager-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if .Values.thanos.ruler.alertmanagers.enabled }}
{{ if and .Values.thanos.ruler.alertmanagers.enabled .Values.thanos.ruler.enabled (not .Values.thanos.query.standalone) }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if and .Values.thanos.ruler.alertmanagers.authentication.enabled .Values.thanos.ruler.alertmanagers.enabled }}
{{ if and .Values.thanos.ruler.alertmanagers.authentication.enabled .Values.thanos.ruler.alertmanagers.enabled .Values.thanos.ruler.enabled (not .Values.thanos.query.standalone) }}
apiVersion: v1
kind: Secret
type: Opaque
Expand Down
2 changes: 1 addition & 1 deletion thanos/charts/templates/ruler/ruler.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if and (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") .Values.thanos.ruler.enabled }}
{{ if and (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") .Values.thanos.ruler.enabled (not .Values.thanos.query.standalone) }}
apiVersion: monitoring.coreos.com/v1
kind: ThanosRuler
metadata:
Expand Down
2 changes: 2 additions & 0 deletions thanos/charts/templates/store-svc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if and .Values.thanos.store.enabled (not .Values.thanos.query.standalone) }}
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -28,3 +29,4 @@ spec:
selector:
app.kubernetes.io/managed-by: {{ include "release.name" . }}
app.kubernetes.io/name: store
{{ end }}
2 changes: 2 additions & 0 deletions thanos/charts/templates/store.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if and .Values.thanos.store.enabled (not .Values.thanos.query.standalone) }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -111,3 +112,4 @@ spec:
secretName: {{ include "release.name" . }}-metrics-objectstore
- name: data
emptyDir: {}
{{ end }}
31 changes: 19 additions & 12 deletions thanos/charts/templates/tests/test-thanos-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,35 @@ data:

DETIK_CLIENT_NAME="kubectl"

@test "Verify successful deployment and running status of {{ .Release.Name }} compactor, query and store" {
verify "there is 1 deployment named '{{ .Release.Name }}-compactor'"
@test "Verify {{ .Release.Name }} Query" {
verify "there is 1 deployment named '{{ .Release.Name }}-query'"
verify "there is 1 deployment named '{{ .Release.Name }}-store'"
verify "there is 1 service named '{{ .Release.Name }}-compactor'"
verify "there is 1 service named '{{ .Release.Name }}-query'"
verify "there is 1 service named '{{ .Release.Name }}-store'"
try "at most 2 times every 5s to get pods named '{{ .Release.Name }}-compactor' and verify that '.status.phase' is 'running'"
try "at most 4 times every 5s to get pods named '{{ .Release.Name }}-query' and verify that '.status.phase' is 'running'"
try "at most 4 times every 5s to get pods named '{{ .Release.Name }}-store' and verify that '.status.phase' is 'running'"
}

{{ if .Values.thanos.ruler.enabled }}
{{ if and .Values.thanos.store.enabled (not .Values.thanos.query.standalone) }}
@test "Verify {{ .Release.Name }} Store" {
verify "there is 1 deployment named '{{ .Release.Name }}-store'"
verify "there is 1 service named '{{ .Release.Name }}-store'"
try "at most 4 times every 5s to get pods named '{{ .Release.Name }}-store' and verify that '.status.phase' is 'running'"
}
{{ end }}

{{ if and .Values.thanos.compactor.enabled (not .Values.thanos.query.standalone) }}
@test "Verify {{ .Release.Name }} Compactor" {
verify "there is 1 deployment named '{{ .Release.Name }}-compactor'"
verify "there is 1 service named '{{ .Release.Name }}-compactor'"
try "at most 3 times every 5s to get pods named '{{ .Release.Name }}-compactor' and verify that '.status.phase' is 'running'"
try "at most 3 times every 5s to get persistentvolumeclaims named '{{ .Release.Name }}-compactor' and verify that '.status.phase' is 'Bound'"
}
{{ end }}

{{ if and .Values.thanos.ruler.enabled (not .Values.thanos.query.standalone) }}
@test "Verify succesful creation, running status and rulefiles population of Thanos Ruler" {
verify "there is 1 statefulset named 'thanos-ruler-{{ .Release.Name }}'"
verify "there is 1 service named 'thanos-ruler-operated'"
try "at most 3 times every 5s to get pods named 'thanos-ruler-{{ .Release.Name }}' and verify that '.status.phase' is 'running'"
try "at most 3 times every 5s to get configmaps named '.*(ruler)+.*(rulefiles)+.*' and verify that '.data' matches '.*yaml.*'"
}
{{ end }}

@test "Verify successful creation and bound status of {{ .Release.Name }} persistent volume claims" {
try "at most 3 times every 5s to get persistentvolumeclaims named '{{ .Release.Name }}-compactor' and verify that '.status.phase' is 'Bound'"
}
{{- end -}}
8 changes: 8 additions & 0 deletions thanos/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,21 @@

additionalArgs: []
# - something.route-foo=/lol

deploymentLabels: {}

containerLabels:

serviceLabels:

annotations:

# if this is a standalone query, store endpoints need to be added here, otherwise the query does nothing.
stores: []
trouaux marked this conversation as resolved.
Show resolved Hide resolved

store:
# if this is a standalone Thanos Query, we wouldn't want a store.
enabled: true
trouaux marked this conversation as resolved.
Show resolved Hide resolved
# adding additional arguments
additionalArgs: []

Expand All @@ -82,6 +87,7 @@
# if this is a standalone Thanos Query, we wouldn't want a compactor
enabled: true
# TODO: store secret needs to be present and can not be provisioned automatically

logLevel:

containerLabels: []
Expand Down Expand Up @@ -128,6 +134,8 @@

labels:

externalPrefix: /ruler

Check failure on line 137 in thanos/charts/values.yaml

View workflow job for this annotation

GitHub Actions / helm-lint-test

137:5 [key-duplicates] duplication of key "externalPrefix" in mapping

alertLabels:

matchLabel:
Expand Down
15 changes: 15 additions & 0 deletions thanos/plugindefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ spec:
name: thanos.query.standalone
required: false
type: bool
- default: true
description: Enable Thanos Store
name: thanos.store.enabled
required: false
type: bool
- default: true
description: Enable Thanos Compactor
name: thanos.compactor.enabled
required: false
type: bool
- default: true
description: Enable Thanos Ruler
name: thanos.ruler.enabled
required: false
type: bool
- default: []
description: Automatically filled if Query is not standalone. If multiple Prometheis are deployed, all Prometheus, Thanos Query and Thanos Store services need to be added to this list manually e.g. kube-monitoring-prometheus:10901 or thanos-store:10901.
name: thanos.query.stores
Expand Down
Loading