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

feat(thanos) ruler component #534

Merged
merged 34 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
46903d6
add ruler + ruler-svc templates
trouaux Nov 29, 2024
654183c
remove label helm.sh
trouaux Nov 29, 2024
2525a23
lint clean up
trouaux Nov 29, 2024
7b0adb2
ruler bats testing + extra labels
trouaux Nov 29, 2024
82884d6
Merge branch 'main' into thanos-ruler-component
trouaux Dec 9, 2024
68c91dc
re-org values + clean-up ruler template
trouaux Dec 9, 2024
a047918
values naming fix
trouaux Dec 12, 2024
5e2d852
update container args + volume mounts
trouaux Dec 12, 2024
eda4ccb
clean up
trouaux Jan 6, 2025
8c674b6
remove comment conflict
trouaux Jan 6, 2025
178b31b
thanos ruler with k8s operator
trouaux Jan 7, 2025
350cfd1
CI test with prometheus operator
trouaux Jan 7, 2025
0f6c944
lint fix + chart lock
trouaux Jan 7, 2025
94c51d7
template objectstore volume for store and compactor
trouaux Jan 7, 2025
12e25c7
relocate CI folder
trouaux Jan 7, 2025
f83bed9
lint
trouaux Jan 7, 2025
5414f41
values indent
trouaux Jan 7, 2025
28dff8a
split ci test ressources
trouaux Jan 8, 2025
4faa807
clean up
trouaux Jan 8, 2025
058d29b
fix bats test + new specs to ruler
trouaux Jan 8, 2025
cbfff2d
test clean up
trouaux Jan 8, 2025
0832396
ruler enabled conditions
trouaux Jan 9, 2025
ad72e24
test typo
trouaux Jan 9, 2025
76240be
update thanos ruler tests
trouaux Jan 9, 2025
c219a5f
CI bug
trouaux Jan 9, 2025
54b4e52
common matching labels for CI
trouaux Jan 9, 2025
5592cb9
yaml typo
trouaux Jan 9, 2025
a33baea
clean up ci yaml values
trouaux Jan 21, 2025
f41ce74
fix suggestions
trouaux Jan 24, 2025
82c5944
alertmanager ressources for ruler config
trouaux Jan 24, 2025
f74464c
feat alertmanager config templates
trouaux Jan 24, 2025
acf165e
fix configmap name
trouaux Jan 24, 2025
1426ac8
rework ruler labels
trouaux Jan 27, 2025
4c832c4
feat: routePrefix
trouaux Jan 27, 2025
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
1 change: 1 addition & 0 deletions .github/configs/helm-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ chart-dirs:
- service-proxy/charts/1.0.0
- logshipper
- opentelemetry
- thanos
chart-repos:
- cert-manager=https://charts.jetstack.io
- alerts=https://prometheus-community.github.io/helm-charts
Expand Down
6 changes: 6 additions & 0 deletions thanos/charts/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: kube-prometheus-stack
repository: https://prometheus-community.github.io/helm-charts
version: 65.4.0
digest: sha256:00f16c99781d187f00cb2063ea2206f192696d5b1e9bae580d322cf9700d2807
generated: "2025-01-07T13:50:40.0294+01:00"
11 changes: 8 additions & 3 deletions thanos/charts/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@

apiVersion: v2
description: Base chart for thanos monitoring deployments
icon: https://raw.githubusercontent.com/thanos-io/thanos/main/docs/img/Thanos-logo_fullmedium.png
icon: https://raw.githubusercontent.com/thanos-io/thanos/main/docs/img/Thanos-logo_fullmedium.png
type: application
maintainers:
- name: viennaa
- name: richardtief
name: thanos
name: thanos
sources:
- https://github.com/cloudoperators/greenhouse-extensions
version: 0.1.3
version: 0.1.4
# thanos-release
appVersion: v0.35.0
keywords:
- thanos
- storage
- metrics
dependencies:
- name: kube-prometheus-stack
alias: prometheus-operator
repository: https://prometheus-community.github.io/helm-charts
version: 65.4.0
trouaux marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
19 changes: 19 additions & 0 deletions thanos/charts/ci/test-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
prometheus-operator:
defaultRules:
create: true
rules:
prometheusOperator: true
labels:
thanos-ruler: thanos
prometheusOperator:
enabled: true
crds:
enabled: true

testFramework:
ci:
enabled: true

thanos:
ruler:
matchLabel: thanos
2 changes: 1 addition & 1 deletion thanos/charts/templates/compactor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ spec:
- name: objectstore-secret
secret:
defaultMode: 420
secretName: {{ include "release.name" . }}-metrics-objectstore
secretName: {{ include "release.name" . }}-metrics-objectstore
- name: data-volume
persistentVolumeClaim:
claimName: {{ include "release.name" . }}-compactor
Expand Down
32 changes: 32 additions & 0 deletions thanos/charts/templates/ruler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/*
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 }}
apiVersion: monitoring.coreos.com/v1
kind: ThanosRuler
metadata:
name: {{ include "release.name" . }} # ressources name = thanos-ruler-<name>
labels:
{{- include "plugin.labels" . | nindent 4 }}
{{- include "thanos.labels" . | nindent 4 }}
{{- if .Values.thanos.ruler.labels }}
{{ toYaml .Values.thanos.ruler.labels | nindent 4 }}
{{- end }}
spec:
image: "{{ .Values.thanos.image.repository }}:{{ .Values.thanos.image.tag | default .Chart.AppVersion }}"
ruleSelector:
matchLabels:
thanos-ruler: {{ .Values.thanos.ruler.matchLabel | default .Release.Name }} # Label for fetching rules
trouaux marked this conversation as resolved.
Show resolved Hide resolved
queryEndpoints:
- {{ include "release.name" . }}-query:10902
alertmanagersConfig:
key: alertManagerConfig.yaml # Key name for alert manager config yaml
name: {{ include "release.name" . }}-alertmanager-config # Secret name containing alert manager config
trouaux marked this conversation as resolved.
Show resolved Hide resolved
# The labels to add to any alert when communicating with Alertmanager
labels:
{{ toYaml .Values.thanos.ruler.alertLabels | nindent 4 }}
# Select rules from all namespaces.
ruleNamespaceSelector: {}
{{ end }}
2 changes: 1 addition & 1 deletion thanos/charts/templates/store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ spec:
- name: objectstore-secret
secret:
defaultMode: 420
secretName: {{ include "release.name" . }}-metrics-objectstore
secretName: {{ include "release.name" . }}-metrics-objectstore
- name: data
emptyDir: {}
21 changes: 21 additions & 0 deletions thanos/charts/templates/tests/test-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.testFramework.ci.enabled -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "release.name" . }}-metrics-objectstore
data:
# Dummy filesystem config as objectstore
thanos.yaml: >-
dHlwZTogRklMRVNZU1RFTQpjb25maWc6CiAgZGlyZWN0b3J5OiAiL3Rlc3QiCnByZWZpeDogIiIKCgogICMga3ViZWN0bCBjcmVhdGUgc2VjcmV0IGdlbmVyaWMgb2JqZWN0LXN0b3JlLXNlY3JldCAtLWZyb20tZmlsZT10aGFub3MueWFtbD0uL3Rlc3Qtc2VjcmV0LnlhbWwgLW4gZGVtbwo=
type: Opaque
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ include "release.name" . }}-alertmanager-config
labels:
thanos: {{ include "release.name" . }}
data:
alertManagerConfig.yaml: ""
{{- end -}}
2 changes: 1 addition & 1 deletion thanos/charts/templates/tests/test-permissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rules:
resources: ["deployments", "statefulsets"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods", "persistentvolumeclaims", "services"]
resources: ["pods", "persistentvolumeclaims", "services", "configmaps"]
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
10 changes: 9 additions & 1 deletion thanos/charts/templates/tests/test-thanos-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ data:
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 }}
@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 -}}
2 changes: 1 addition & 1 deletion thanos/charts/templates/tests/test-thanos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ spec:
configMap:
name: {{ .Release.Name }}-test
restartPolicy: Never
{{- end -}}
{{- end -}}
105 changes: 91 additions & 14 deletions thanos/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

global:

## Labels to apply to all resources
##
commonLabels: {}

thanos:
Expand All @@ -13,9 +11,9 @@ thanos:
# defaults to .Chart.appVersion
tag:
# defaults to IfNotPresent
pullPolicy:
pullPolicy:
grpcAddress:
# used across the stack
# used across the stack
httpAddress:

query:
Expand All @@ -36,36 +34,39 @@ thanos:
routePrefix:

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

deploymentLabels: {}

# - something.route-foo=/lol
deploymentLabels: {}
containerLabels:

serviceLabels:

annotations:

stores: []
stores: []

store:
# adding additional arguments
additionalArgs: []

deploymentLabels: {}
deploymentLabels: {}

containerLabels:

#TODO use
# TODO use
viennaa marked this conversation as resolved.
Show resolved Hide resolved
serviceLabels:

annotations:

chunkPoolSize:

indexCacheSize:

logLevel:

compactor:
# 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 All @@ -74,7 +75,7 @@ thanos:

labels: []
annotations: []

# adding additional arguments
additionalArgs: []

Expand All @@ -93,7 +94,7 @@ thanos:
# seconds
cleanupInterval:

# seconds
# seconds
waitInterval:

volume:
Expand All @@ -103,10 +104,86 @@ thanos:
size:
labels: []

ruler:
enabled: true

labels:

alertLabels:

testFramework:
enabled: true
image:
registry: ghcr.io
repository: cloudoperators/greenhouse-extensions-integration-test
tag: main
imagePullPolicy: IfNotPresent
## only TRUE for CI ! see test-ci.yaml
ci:
enabled: false

# Only used for TESTING !!!
# The kube-monitoring plugin is taking care of deploying the Prometheus Operator
# Thanos Plugin leverages it for its CI
prometheus-operator:
defaultRules:
create: false
rules:
alertmanager: false
etcd: false
configReloaders: false
general: false
k8sContainerCpuUsageSecondsTotal: false
k8sContainerMemoryCache: false
k8sContainerMemoryRss: false
k8sContainerMemorySwap: false
k8sContainerResource: false
k8sPodOwner: false
kubeApiserverAvailability: false
kubeApiserverBurnrate: false
kubeApiserverHistogram: false
kubeApiserverSlos: false
kubeControllerManager: false
kubelet: false
kubeProxy: false
kubePrometheusGeneral: false
kubePrometheusNodeRecording: false
kubernetesApps: false
kubernetesResources: false
kubernetesStorage: false
kubernetesSystem: false
kubeSchedulerAlerting: false
kubeSchedulerRecording: false
kubeStateMetrics: false
network: false
node: false
nodeExporterAlerting: false
nodeExporterRecording: false
prometheus: false
prometheusOperator: false
windows: false
viennaa marked this conversation as resolved.
Show resolved Hide resolved
dashboards:
create: false
kubernetesServiceMonitors:
enabled: false
cleanPrometheusOperatorObjectNames: false
crds:
enabled: false
windowsMonitoring:
enabled: false
grafana:
enabled: false
thanosRuler:
enabled: false
prometheus:
enabled: false
nodeExporter:
enabled: false
kubeStateMetrics:
enabled: false
prometheusOperator:
enabled: false
alertmanager:
enabled: false
ingress:
enabled: false
Loading