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

[WIP] thanos ruler compoment #534

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
33 changes: 33 additions & 0 deletions thanos/charts/templates/ruler-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if .Values.thanos.ruler.enabled }}
apiVersion: v1
kind: Service
metadata:
{{- if .Values.thanos.query.annotations }}
annotations:
{{ toYaml .Values.thanos.query.annotations | nindent 8 }}
{{- end }}
labels:
{{- include "plugin.labels" . | nindent 4 }}
{{- include "thanos.labels" . | nindent 4 }}
{{- if .Values.thanos.ruler.serviceLabels }}
{{ toYaml .Values.thanos.ruler.serviceLabels | nindent 4 }}
{{- end }}
name: {{ include "release.name" . }}-ruler
spec:
ports:
- name: grpc
port: 10901
protocol: TCP
targetPort: grpc
- name: http
port: 10902
protocol: TCP
targetPort: http
selector:
app.kubernetes.io/managed-by: {{ include "release.name" . }}
app.kubernetes.io/name: ruler

{{- end }}
98 changes: 98 additions & 0 deletions thanos/charts/templates/ruler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# {{ if .Values.thanos.ruler.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
{{- include "plugin.labels" . | nindent 4 }}
{{- include "thanos.labels" . | nindent 4 }}
{{- if .Values.thanos.ruler.deploymentLabels }}
{{ toYaml .Values.thanos.ruler.deploymentLabels | nindent 4 }}
{{- end }}
name: {{ include "release.name" . }}-ruler
spec:
replicas: {{ default 1 .Values.thanos.ruler.replicas }}
updateStrategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
selector:
matchLabels:
app.kubernetes.io/name: {{ include "release.name" . }}-ruler
app.kubernetes.io/instance: {{ .Release.Name }}
serviceName: {{ include "release.name" . }}-ruler
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "release.name" . }}-ruler
app.kubernetes.io/instance: {{ .Release.Name }}
prometheus-thanos-peer: "true"
{{- with .Values.thanos.ruler.additionalLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
region: {{ .Values.global.region }}
cluster_type: {{ .Values.global.clusterType }}
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "10902"
spec:
serviceAccount: {{ include "release.name" . }}-ruler
containers:
- name: {{ .Chart.Name }}-ruler
imagePullPolicy: {{ default "IfNotPresent" .Values.thanos.image.pullPolicy }}
image: "{{ .Values.thanos.image.repository }}:{{ .Values.thanos.image.tag | default .Chart.AppVersion }}"
args:
- rule
- --data-dir=/thanos/data
- --log.level={{ .Values.thanos.ruler.logLevel }}
- --eval-interval={{ .Values.thanos.ruler.evalInterval }}
- --tsdb.retention=24h
- --rule-file=/etc/thanos/rules/*/*.yaml
- --query={{ include "release.name" . }}-query:10902
- --label=thanos_ruler_replica="$(POD_NAME)"
- --label=cluster="qa-de-1"
- --label=cluster_type="metal"
- --label=region="qa-de-1"
- --alert.label-drop=thanos_ruler_replica
- --alertmanagers.config-file=/etc/thanos/config/alertmanager-config/alertManagerConfig.yaml
- --web.external-prefix=/ruler
- --web.route-prefix=/ruler
- --alert.query-url=https://metrics.metal.qa-de-1.cloud.sap
- --http.config=/etc/thanos/web_config/web-config.yaml
ports:
- name: http
containerPort: 10902
protocol: TCP
- name: grpc
containerPort: 10901
protocol: TCP
volumeMounts:
- mountPath: /etc/thanos/rules/{{ include "release.name" . }}-rulefiles
name: {{ include "release.name" . }}-rulefiles
- mountPath: /etc/thanos/config/alertmanager-config
name: alertmanager-config
- mountPath: /etc/thanos/web_config/web-config.yaml
name: web-config
- mountPath: /etc/thanos/secrets/thanos-metal-ruler-alertmanager-sso-cert
name: {{ include "release.name" . }}-alertmanager-sso-cert
- mountPath: /thanos/data
name: data
volumes:
- name: alertmanager-config
secret:
defaultMode: 420
secretName: {{ include "release.name" . }}-alertmanager-config
- name: web-config
secret:
defaultMode: 420
secretName: {{ include "release.name" . }}-web-config
- name: {{ include "release.name" . }}-alertmanager-sso-cert
secret:
defaultMode: 420
secretName: {{ include "release.name" . }}-ruler-alertmanager-sso-cert
- name: {{ include "release.name" . }}-rulefiles #what if multiple replicas ?
configMap:
name: {{ include "release.name" . }}-rulerrulefiles
- name: data
emptyDir: {}
# {{- end }}
3 changes: 3 additions & 0 deletions thanos/charts/templates/tests/test-thanos-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ data:
verify "there is 1 deployment named '{{ .Release.Name }}-compactor'"
verify "there is 1 deployment named '{{ .Release.Name }}-query'"
verify "there is 1 deployment named '{{ .Release.Name }}-store'"
verify "there is 1 statefulset named '{{ .Release.Name }}-ruler'"
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'"
verify "there is 1 service named '{{ .Release.Name }}-ruler'"
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'"
try "at most 4 times every 5s to get pods named '{{ .Release.Name }}-ruler' and verify that '.status.phase' is 'running'"
}

@test "Verify successful creation and bound status of {{ .Release.Name }} persistent volume claims" {
Expand Down
57 changes: 57 additions & 0 deletions thanos/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
# SPDX-License-Identifier: Apache-2.0

global:
clusterType:

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

# Create RBAC resources.
rbac:
create: true

# ServiceAccount to use for the Thanos.
# Note that a ServiceAccount with name `default` cannot be created.
# Instead the generated name will be used.
serviceAccount:
create: true

thanos:
image:
repository: quay.io/thanos/thanos
Expand Down Expand Up @@ -61,6 +73,12 @@ thanos:

annotations:

chunkPoolSize:

indexCacheSize:

logLevel:

compactor:
# if this is a standalone Thanos Query, we wouldn't want a compactor
enabled: true
Expand Down Expand Up @@ -102,6 +120,45 @@ thanos:
# GiB
size:
labels: []

ruler:
enabled: true

replicas:

annotations:

deploymentLabels: {}

serviceLabels:

paused:

logLevel:

externalPrefix:

evalInterval: 30s

externalClusterLabels:
enabled:

alertmanagers:
hosts:
authentication:
enabled:

queryEndpoints:

queries:

additionalFlags:

additionalLabels:

externalUrl: "https://"

retention: true

testFramework:
enabled: true
Expand Down
Loading