Skip to content

Commit

Permalink
add ruler and ruler-svc template
Browse files Browse the repository at this point in the history
  • Loading branch information
trouaux committed Nov 27, 2024
1 parent 84cd94e commit 6d0aa6f
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
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.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.ruler.serviceLabels }}
{{ toYaml .Values.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 }}
85 changes: 85 additions & 0 deletions thanos/charts/templates/ruler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

{{ if .Values.ruler.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
{{- include "plugin.labels" . | nindent 4 }}
{{- include "thanos.labels" . | nindent 4 }}
{{- if .Values.ruler.deploymentLabels }}
{{ toYaml .Values.ruler.deploymentLabels | nindent 4 }}
{{- end }}
name: {{ include "release.name" . }}-ruler

spec:
image: "{{ .Values.thanos.image.repository }}:{{ .Values.thanos.image.tag | default .Chart.AppVersion }}"
paused: {{ $.Values.ruler.paused }}
logLevel: {{ default "info" $.Values.ruler.logLevel }}
retention: {{ $.Values.ruler.retention | quote | default true }}
{{- if $.Values.rbac.create }}
serviceAccountName: {{ include "release.name" . }}-ruler
{{- end }}
{{- if $.Values.ruler.externalPrefix }}
# if externalPrefix is set, the routePrefix must also be set so that http handlers can be registered there
externalPrefix: {{ $.Values.ruler.externalPrefix }}
routePrefix: {{ $.Values.ruler.externalPrefix }}
{{- end }}
{{- if $.Values.ruler.evaluationInterval }}
evaluationInterval: {{ $.Values.ruler.evaluationInterval }}
{{- end }}
ruleSelector: #???
matchLabels:
thanos-ruler: {{ include "release.name" . }}-ruler

# Select rules from all namespaces.
ruleNamespaceSelector: {}

# The labels to add to any alert when communicating with Alertmanager
labels:
region: {{ required ".Values.global.region missing" $.Values.global.region }}
{{- if $.Values.ruler.externalClusterLabels.enabled }}
cluster: {{ if $.Values.global.cluster }}{{ $.Values.global.cluster }}{{ else }}{{ $.Values.global.region }}
{{- end }}
cluster_type: {{ required ".Values.global.clusterType missing" $.Values.global.clusterType }}
{{- else }}
cluster: {{ required ".Values.global.region missing" $.Values.global.region }}
{{- end }}
alertQueryUrl: {{ $.Values.ruler.externalUrl }} # ???
{{ if required "$.Values.ruler.alertmanagers.hosts missing" $.Values.ruler.alertmanagers.hosts }}
alertmanagersConfig:
name: {{ include "release.name" . }}-alertmanager-config # ???
key: alertManagerConfig.yaml
{{- end }}

{{- if and $.Values.global.linkerd_enabled $.Values.global.linkerd_requested }}
podMetadata:
annotations:
linkerd.io/inject: enabled
{{- end }}

{{ if not $.Values.ruler.queryEndpoints }}
queryEndpoints:
- {{ include "release.name" . }}-query:10902 #???
{{- else }}
{{ toYaml $.Values.ruler.queryEndpoints | indent 4 }}
{{- end }}

{{- if $.Values.ruler.resources }}
resources:
{{ toYaml $.Values.ruler.resources | indent 4 }}
{{- end }}
{{- if $.Values.ruler.alertmanagers.authentication.enabled }}
containers:
- name: thanos-ruler
volumeMounts:
- mountPath: /etc/thanos/secrets/{{ include "release.name" . }}-ruler-alertmanager-sso-cert #???
name: {{ include "release.name" . }}-ruler-alertmanager-sso-cert #???
readOnly: true
volumes:
- name: {{ include "release.name" . }}-ruler-alertmanager-sso-cert #???
secret:
secretName: {{ include "release.name" . }}-ruler-alertmanager-sso-cert #???
{{- end }}
{{- end }}
45 changes: 45 additions & 0 deletions thanos/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,56 @@
# 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

ruler:
enabled: true

annotations:

deploymentLabels: {}

serviceLabels:

paused:

logLevel:

externalPrefix:

evaluationInterval:

externalClusterLabels:
enabled:

alertmanagers:
hosts:
authentication:
enabled:

queryEndpoints:

resources:

externalUrl: "https://"

retention: true

thanos:
image:
repository: quay.io/thanos/thanos
Expand Down

0 comments on commit 6d0aa6f

Please sign in to comment.