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

[prometheus-kube-stack] Fixes deployment of Thanos Ruler - Addresses Default Thanos Ruler name too long #3021

Merged
merged 2 commits into from
Feb 14, 2023
Merged
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
2 changes: 1 addition & 1 deletion charts/kube-prometheus-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name: kube-prometheus-stack
sources:
- https://github.com/prometheus-community/helm-charts
- https://github.com/prometheus-operator/kube-prometheus
version: 45.0.0
version: 45.0.1
appVersion: v0.63.0
kubeVersion: ">=1.16.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
8 changes: 7 additions & 1 deletion charts/kube-prometheus-stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ The longest name that gets created adds and extra 37 characters, so truncation s
{{- printf "%s-thanos-ruler" (include "kube-prometheus-stack.fullname" .) -}}
{{- end }}

{{/* Shortened name suffixed with thanos-ruler */}}
{{- define "kube-prometheus-stack.thanosRuler.name" -}}
{{- default (printf "%s-thanos-ruler" (include "kube-prometheus-stack.name" .)) .Values.thanosRuler.name -}}
{{- end }}


{{/* Create chart name and version as used by the chart label. */}}
{{- define "kube-prometheus-stack.chartref" -}}
{{- replace "+" "_" .Chart.Version | printf "%s-%s" .Chart.Name -}}
Expand Down Expand Up @@ -106,7 +112,7 @@ heritage: {{ $.Release.Service | quote }}
{{/* Create the name of thanosRuler service account to use */}}
{{- define "kube-prometheus-stack.thanosRuler.serviceAccountName" -}}
{{- if .Values.thanosRuler.serviceAccount.create -}}
{{ default (include "kube-prometheus-stack.thanosRuler.fullname" .) .Values.thanosRuler.serviceAccount.name }}
{{ default (include "kube-prometheus-stack.thanosRuler.name" .) .Values.thanosRuler.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.thanosRuler.serviceAccount.name }}
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.thanosRuler.extraSecret.data -}}
{{- $secretName := printf "thanos-ruler-%s-extra" (include "kube-prometheus-stack.fullname" . ) -}}
{{- $secretName := printf "%s-extra" (include "kube-prometheus-stack.thanosRuler.name" . ) -}}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -10,7 +10,7 @@ metadata:
{{ toYaml .Values.thanosRuler.extraSecret.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
app.kubernetes.io/component: thanos-ruler
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
data:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if and .Values.thanosRuler.enabled .Values.thanosRuler.ingress.enabled }}
{{- $pathType := .Values.thanosRuler.ingress.pathType | default "ImplementationSpecific" }}
{{- $serviceName := printf "%s-%s" (include "kube-prometheus-stack.fullname" .) "thanos-ruler" }}
{{- $serviceName := include "kube-prometheus-stack.thanosRuler.name" . }}
{{- $servicePort := .Values.thanosRuler.service.port -}}
{{- $routePrefix := list .Values.thanosRuler.thanosRulerSpec.routePrefix }}
{{- $paths := .Values.thanosRuler.ingress.paths | default $routePrefix -}}
Expand All @@ -16,7 +16,7 @@ metadata:
{{ toYaml .Values.thanosRuler.ingress.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
{{- if .Values.thanosRuler.ingress.labels }}
{{ toYaml .Values.thanosRuler.ingress.labels | indent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
apiVersion: {{ include "kube-prometheus-stack.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
name: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
spec:
{{- if .Values.thanosRuler.podDisruptionBudget.minAvailable }}
Expand All @@ -17,5 +17,5 @@ spec:
selector:
matchLabels:
app.kubernetes.io/name: thanos-ruler
thanos-ruler: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
thanos-ruler: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
{{- end }}
12 changes: 6 additions & 6 deletions charts/kube-prometheus-stack/templates/thanos-ruler/ruler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
apiVersion: monitoring.coreos.com/v1
kind: ThanosRuler
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
name: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
app: {{ include "kube-prometheus-stack.thanosRuler.name" . }}
{{- include "kube-prometheus-stack.labels" . | indent 4 -}}
{{- if .Values.thanosRuler.annotations }}
annotations:
{{ toYaml .Values.thanosRuler.annotations | indent 4 }}
Expand Down Expand Up @@ -35,7 +35,7 @@ spec:
{{- else if and .Values.thanosRuler.ingress.enabled .Values.thanosRuler.ingress.hosts }}
externalPrefix: "http://{{ tpl (index .Values.thanosRuler.ingress.hosts 0) . }}{{ .Values.thanosRuler.thanosRulerSpec.routePrefix }}"
{{- else }}
externalPrefix: http://{{ template "kube-prometheus-stack.fullname" . }}-thanosRuler.{{ template "kube-prometheus-stack.namespace" . }}:{{ .Values.thanosRuler.service.port }}
externalPrefix: http://{{ template "kube-prometheus-stack.thanosRuler.name" . }}.{{ template "kube-prometheus-stack.namespace" . }}:{{ .Values.thanosRuler.service.port }}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.nodeSelector }}
nodeSelector:
Expand Down Expand Up @@ -126,7 +126,7 @@ spec:
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [thanos-ruler]}
- {key: thanos-ruler, operator: In, values: [{{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler]}
- {key: thanos-ruler, operator: In, values: [{{ template "kube-prometheus-stack.thanosRuler.name" . }}]}
{{- else if eq .Values.thanosRuler.thanosRulerSpec.podAntiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
Expand All @@ -136,7 +136,7 @@ spec:
labelSelector:
matchExpressions:
- {key: app.kubernetes.io/name, operator: In, values: [thanos-ruler]}
- {key: thanos-ruler, operator: In, values: [{{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler]}
- {key: thanos-ruler, operator: In, values: [{{ template "kube-prometheus-stack.thanosRuler.name" . }}]}
{{- end }}
{{- if .Values.thanosRuler.thanosRulerSpec.tolerations }}
tolerations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
name: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
self-monitor: {{ .Values.thanosRuler.serviceMonitor.selfMonitor | quote }}
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.labels" . | indent 4 -}}
{{- if .Values.thanosRuler.service.labels }}
{{ toYaml .Values.thanosRuler.service.labels | indent 4 }}
{{- end }}
Expand Down Expand Up @@ -48,6 +48,6 @@ spec:
{{- end }}
selector:
app.kubernetes.io/name: thanos-ruler
thanos-ruler: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
thanos-ruler: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
type: "{{ .Values.thanosRuler.service.type }}"
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ metadata:
name: {{ template "kube-prometheus-stack.thanosRuler.serviceAccountName" . }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app.kubernetes.io/name: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
app.kubernetes.io/name: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
app.kubernetes.io/component: thanos-ruler
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
{{- include "kube-prometheus-stack.labels" . | indent 4 -}}
{{- if .Values.thanosRuler.serviceAccount.annotations }}
annotations:
{{ toYaml .Values.thanosRuler.serviceAccount.annotations | indent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-ruler
name: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
spec:
{{- include "servicemonitor.scrapeLimits" .Values.thanosRuler.serviceMonitor | nindent 2 }}
selector:
matchLabels:
app: {{ template "kube-prometheus-stack.name" . }}-thanos-ruler
app: {{ template "kube-prometheus-stack.thanosRuler.name" . }}
release: {{ $.Release.Name | quote }}
self-monitor: {{ .Values.thanosRuler.serviceMonitor.selfMonitor | quote }}
namespaceSelector:
Expand Down