Skip to content

Commit

Permalink
add ruler + ruler-svc templates
Browse files Browse the repository at this point in the history
  • Loading branch information
trouaux committed Nov 29, 2024
1 parent 84cd94e commit 46903d6
Show file tree
Hide file tree
Showing 3 changed files with 271 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 }}
191 changes: 191 additions & 0 deletions thanos/charts/templates/ruler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
{{- if .Values.ruler.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "release.name" . }}-ruler
labels:
app.kubernetes.io/name: {{ include "release.name" . }}-ruler
helm.sh/chart: {{ include "prometheus-thanos.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "plugin.labels" . | nindent 4 }}
{{- include "thanos.labels" . | nindent 4 }}
{{- if .Values.ruler.deploymentLabels }}
{{ toYaml .Values.ruler.deploymentLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.ruler.replicaCount }}
updateStrategy:
type: {{ .Values.ruler.updateStrategy }}
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.ruler.additionalLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "10902"
spec:
serviceAccount: {{ include "release.name" . }}-ruler
# {{- with .Values.ruler.imagePullSecrets }}
# imagePullSecrets:
# {{- toYaml . | nindent 8 }}
# {{- end }}
containers:
- name: {{ .Chart.Name }}-ruler
imagePullPolicy: {{ .Values.ruler.image.pullPolicy }}
image: "{{ .Values.thanos.image.repository }}:{{ .Values.thanos.image.tag | default .Chart.AppVersion }}"
args:
- rule
- --data-dir=/data
- --log.level={{ .Values.ruler.logLevel }}
- --eval-interval={{ .Values.ruler.evalInterval }}
- --rule-file={{ .Values.ruler.ruleFile }}
- --alertmanagers.url={{ .Values.ruler.alertmanagerUrl }}
- --query={{ include "release.name" . }}-querier:{{ .Values.service.querier.http.port }}
{{- range .Values.ruler.queries }}
- --query={{ . }}
{{- end }}
{{- if .Values.ruler.objStoreType }}
- |
--objstore.config=type: {{ .Values.ruler.objStoreType }}
config:
{{- toYaml .Values.ruler.objStoreConfig | nindent 14 }}
{{ else if .Values.ruler.objStoreConfigFile }}
- --objstore.config-file={{ .Values.ruler.objStoreConfigFile }}
{{- end }}
{{- range $key, $value := .Values.ruler.additionalFlags }}
- "--{{ $key }}{{if $value }}={{ $value }}{{end}}"
{{- end }}
- --label=ruler_cluster="{{ .Values.ruler.clusterName }}"
- --label=replica="$(POD_NAME)"
{{- if .Values.tracing.enabled }}
- |
--tracing.config=type: {{ .Values.tracing.type }}
config:
{{- toYaml .Values.tracing.config | nindent 14 }}
{{- end }}
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
ports:
- name: http
containerPort: 10902
protocol: TCP
- name: grpc
containerPort: 10901
protocol: TCP
resources:
{{- toYaml .Values.ruler.resources | nindent 12 }}
# securityContext:
# {{- toYaml .Values.ruler.containerSecurityContext | nindent 12 }}
volumeMounts:
- mountPath: /etc/thanos-ruler
name: config
- mountPath: /etc/thanos-ruler/external
name: external-config-volume
- mountPath: /data
name: storage-volume
# {{- with .Values.ruler.volumeMounts }}
# {{- toYaml . | nindent 10 }}
# {{- end }}
# {{- if .Values.ruler.sidecar.enabled }}
# - env:
# - name: LABEL
# value: {{ .Values.ruler.sidecar.watchLabel }}
# - name: FOLDER
# value: /etc/config
# - name: NAMESPACE
# value: ALL
# - name: REQ_URL
# value: http://127.0.0.1:10902/-/reload
# - name: REQ_METHOD
# value: POST
# imagePullPolicy: {{ .Values.ruler.sidecar.image.pullPolicy }}
# image: "{{ .Values.ruler.sidecar.image.repository }}:{{ .Values.ruler.sidecar.image.tag }}"
# name: k8s-configmap-watcher
# resources:
# limits:
# cpu: 20m
# memory: 64Mi
# requests:
# cpu: 10m
# memory: 32Mi
# terminationMessagePath: /dev/termination-log
# terminationMessagePolicy: File
# volumeMounts:
# - mountPath: /etc/config
# name: external-config-volume
# {{- end }}
# {{- with .Values.ruler.nodeSelector }}
# nodeSelector:
# {{- toYaml . | nindent 8 }}
# {{- end }}
# {{- with .Values.ruler.affinity }}
# affinity:
# {{- toYaml . | nindent 8 }}
# {{- end }}
# {{- with .Values.ruler.tolerations }}
# tolerations:
# {{- toYaml . | nindent 6 }}
# {{- end }}
# {{- with .Values.ruler.podSecurityContext }}
# securityContext:
# {{- toYaml . | nindent 8 }}
# {{- end }}
volumes:
- name: external-config-volume
emptyDir: {}
- configMap:
name: {{ include "release.name" . }}-ruler
name: config
{{- with .Values.ruler.volumes }}
{{- toYaml . | nindent 6 }}
{{- end }}
# {{- if not .Values.ruler.persistentVolume.enabled }}
# - name: storage-volume
# emptyDir: {}
# {{- else if .Values.ruler.persistentVolume.existingClaim }}
# - name: storage-volume
# persistentVolumeClaim:
# claimName: {{ .Values.ruler.persistentVolume.existingClaim }}
# {{- end }}
# {{- if .Values.ruler.podNumericalPriorityEnabled }}
# priority: {{ .Values.ruler.podPriority }}
# {{- else if .Values.ruler.podPriorityClassName }}
# priorityClassName: {{ .Values.ruler.podPriorityClassName }}
# {{- end }}
# {{- if and .Values.ruler.persistentVolume.enabled (not .Values.ruler.persistentVolume.existingClaim) }}
# volumeClaimTemplates:
# - metadata:
# name: storage-volume
# {{- if .Values.ruler.persistentVolume.annotations }}
# annotations:
# {{- toYaml .Values.ruler.persistentVolume.annotations | nindent 10 }}
# {{- end }}
# spec:
# accessModes:
# {{- toYaml .Values.ruler.persistentVolume.accessModes | nindent 10 }}
# resources:
# requests:
# storage: "{{ .Values.ruler.persistentVolume.size }}"
# {{- if .Values.ruler.persistentVolume.storageClass }}
# {{- if (eq "-" .Values.ruler.persistentVolume.storageClass) }}
# storageClassName: ""
# {{- else }}
# storageClassName: "{{ .Values.ruler.persistentVolume.storageClass }}"
# {{- end }}
# {{- end }}
# {{- end }}
{{- end }}
47 changes: 47 additions & 0 deletions thanos/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,58 @@
# 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
image:
pullPolicy: "IfNotPresent"

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

0 comments on commit 46903d6

Please sign in to comment.