diff --git a/charts/kube-prometheus-stack/Chart.yaml b/charts/kube-prometheus-stack/Chart.yaml index 9eda75c384e9..ff889778d6d8 100644 --- a/charts/kube-prometheus-stack/Chart.yaml +++ b/charts/kube-prometheus-stack/Chart.yaml @@ -23,7 +23,7 @@ name: kube-prometheus-stack sources: - https://github.com/prometheus-community/helm-charts - https://github.com/prometheus-operator/kube-prometheus -version: 35.2.0 +version: 35.2.1 appVersion: 0.56.2 kubeVersion: ">=1.16.0-0" home: https://github.com/prometheus-operator/kube-prometheus diff --git a/charts/kube-prometheus-stack/templates/_helpers.tpl b/charts/kube-prometheus-stack/templates/_helpers.tpl index 54513d3f3fde..f90d9ebd2b15 100644 --- a/charts/kube-prometheus-stack/templates/_helpers.tpl +++ b/charts/kube-prometheus-stack/templates/_helpers.tpl @@ -34,11 +34,29 @@ The longest name that gets created adds and extra 37 characters, so truncation s {{- printf "%s-prometheus" (include "kube-prometheus-stack.fullname" .) -}} {{- end }} +{{/* Prometheus custom resource instance name */}} +{{- define "kube-prometheus-stack.prometheus.crname" -}} +{{- if .Values.cleanPrometheusOperatorObjectNames }} +{{- include "kube-prometheus-stack.fullname" . }} +{{- else }} +{{- printf "%s-prometheus" (include "kube-prometheus-stack.fullname" .) }} +{{- end }} +{{- end }} + {{/* Fullname suffixed with alertmanager */}} {{- define "kube-prometheus-stack.alertmanager.fullname" -}} {{- printf "%s-alertmanager" (include "kube-prometheus-stack.fullname" .) -}} {{- end }} +{{/* Alertmanager custom resource instance name */}} +{{- define "kube-prometheus-stack.alertmanager.crname" -}} +{{- if .Values.cleanPrometheusOperatorObjectNames }} +{{- include "kube-prometheus-stack.fullname" . }} +{{- else }} +{{- printf "%s-alertmanager" (include "kube-prometheus-stack.fullname" .) -}} +{{- end }} +{{- 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 -}} diff --git a/charts/kube-prometheus-stack/templates/alertmanager/alertmanager.yaml b/charts/kube-prometheus-stack/templates/alertmanager/alertmanager.yaml index 83284cd13987..a8ec48ff93cd 100644 --- a/charts/kube-prometheus-stack/templates/alertmanager/alertmanager.yaml +++ b/charts/kube-prometheus-stack/templates/alertmanager/alertmanager.yaml @@ -2,7 +2,7 @@ apiVersion: monitoring.coreos.com/v1 kind: Alertmanager metadata: - name: {{ template "kube-prometheus-stack.fullname" . }} + name: {{ template "kube-prometheus-stack.alertmanager.crname" . }} namespace: {{ template "kube-prometheus-stack.namespace" . }} labels: app: {{ template "kube-prometheus-stack.name" . }}-alertmanager @@ -104,7 +104,7 @@ spec: labelSelector: matchExpressions: - {key: app.kubernetes.io/name, operator: In, values: [alertmanager]} - - {key: alertmanager, operator: In, values: [{{ template "kube-prometheus-stack.fullname" . }}]} + - {key: alertmanager, operator: In, values: [{{ template "kube-prometheus-stack.alertmanager.crname" . }}]} {{- else if eq .Values.alertmanager.alertmanagerSpec.podAntiAffinity "soft" }} podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: @@ -114,7 +114,7 @@ spec: labelSelector: matchExpressions: - {key: app.kubernetes.io/name, operator: In, values: [alertmanager]} - - {key: alertmanager, operator: In, values: [{{ template "kube-prometheus-stack.fullname" . }}]} + - {key: alertmanager, operator: In, values: [{{ template "kube-prometheus-stack.alertmanager.crname" . }}]} {{- end }} {{- if .Values.alertmanager.alertmanagerSpec.tolerations }} tolerations: diff --git a/charts/kube-prometheus-stack/templates/alertmanager/podDisruptionBudget.yaml b/charts/kube-prometheus-stack/templates/alertmanager/podDisruptionBudget.yaml index 1c598d3e77af..b18340312531 100644 --- a/charts/kube-prometheus-stack/templates/alertmanager/podDisruptionBudget.yaml +++ b/charts/kube-prometheus-stack/templates/alertmanager/podDisruptionBudget.yaml @@ -17,5 +17,5 @@ spec: selector: matchLabels: app.kubernetes.io/name: alertmanager - alertmanager: {{ template "kube-prometheus-stack.fullname" . }} + alertmanager: {{ template "kube-prometheus-stack.alertmanager.crname" . }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/alertmanager/secret.yaml b/charts/kube-prometheus-stack/templates/alertmanager/secret.yaml index b6a1a305703e..0a354a3bd95f 100644 --- a/charts/kube-prometheus-stack/templates/alertmanager/secret.yaml +++ b/charts/kube-prometheus-stack/templates/alertmanager/secret.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Secret metadata: - name: alertmanager-{{ template "kube-prometheus-stack.fullname" . }} + name: alertmanager-{{ template "kube-prometheus-stack.alertmanager.crname" . }} namespace: {{ template "kube-prometheus-stack.namespace" . }} {{- if .Values.alertmanager.secret.annotations }} annotations: diff --git a/charts/kube-prometheus-stack/templates/alertmanager/service.yaml b/charts/kube-prometheus-stack/templates/alertmanager/service.yaml index 95b3278f0bc3..44100ec1cc6e 100644 --- a/charts/kube-prometheus-stack/templates/alertmanager/service.yaml +++ b/charts/kube-prometheus-stack/templates/alertmanager/service.yaml @@ -48,6 +48,6 @@ spec: {{- end }} selector: app.kubernetes.io/name: alertmanager - alertmanager: {{ template "kube-prometheus-stack.fullname" . }} + alertmanager: {{ template "kube-prometheus-stack.alertmanager.crname" . }} type: "{{ .Values.alertmanager.service.type }}" {{- end }} diff --git a/charts/kube-prometheus-stack/templates/alertmanager/serviceperreplica.yaml b/charts/kube-prometheus-stack/templates/alertmanager/serviceperreplica.yaml index cede0f11585b..75a13bdf9729 100644 --- a/charts/kube-prometheus-stack/templates/alertmanager/serviceperreplica.yaml +++ b/charts/kube-prometheus-stack/templates/alertmanager/serviceperreplica.yaml @@ -42,8 +42,8 @@ items: targetPort: {{ $serviceValues.targetPort }} selector: app.kubernetes.io/name: alertmanager - alertmanager: {{ template "kube-prometheus-stack.fullname" $ }} - statefulset.kubernetes.io/pod-name: alertmanager-{{ include "kube-prometheus-stack.fullname" $ }}-{{ $i }} + alertmanager: {{ template "kube-prometheus-stack.alertmanager.crname" $ }} + statefulset.kubernetes.io/pod-name: alertmanager-{{ include "kube-prometheus-stack.alertmanager.crname" $ }}-{{ $i }} type: "{{ $serviceValues.type }}" {{- end }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/grafana/configmaps-datasources.yaml b/charts/kube-prometheus-stack/templates/grafana/configmaps-datasources.yaml index 9a0a27a4d077..215ce2f7b3b8 100644 --- a/charts/kube-prometheus-stack/templates/grafana/configmaps-datasources.yaml +++ b/charts/kube-prometheus-stack/templates/grafana/configmaps-datasources.yaml @@ -39,7 +39,7 @@ data: - name: Prometheus-{{ . }} type: prometheus uid: {{ .Values.grafana.sidecar.datasources.uid }}-replica-{{ . }} - url: http://prometheus-{{ template "kube-prometheus-stack.fullname" $ }}-{{ . }}.prometheus-operated:9090/{{ trimPrefix "/" $.Values.prometheus.prometheusSpec.routePrefix }} + url: http://prometheus-{{ template "kube-prometheus-stack.prometheus.crname" $ }}-{{ . }}.prometheus-operated:9090/{{ trimPrefix "/" $.Values.prometheus.prometheusSpec.routePrefix }} access: proxy isDefault: false jsonData: diff --git a/charts/kube-prometheus-stack/templates/prometheus/podDisruptionBudget.yaml b/charts/kube-prometheus-stack/templates/prometheus/podDisruptionBudget.yaml index f26b23aa8abc..02a320eff43e 100644 --- a/charts/kube-prometheus-stack/templates/prometheus/podDisruptionBudget.yaml +++ b/charts/kube-prometheus-stack/templates/prometheus/podDisruptionBudget.yaml @@ -17,5 +17,5 @@ spec: selector: matchLabels: app.kubernetes.io/name: prometheus - prometheus: {{ template "kube-prometheus-stack.fullname" . }} + prometheus: {{ template "kube-prometheus-stack.prometheus.crname" . }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/prometheus/prometheus.yaml b/charts/kube-prometheus-stack/templates/prometheus/prometheus.yaml index e4c7650f15e5..586c574914f4 100644 --- a/charts/kube-prometheus-stack/templates/prometheus/prometheus.yaml +++ b/charts/kube-prometheus-stack/templates/prometheus/prometheus.yaml @@ -2,7 +2,7 @@ apiVersion: monitoring.coreos.com/v1 kind: Prometheus metadata: - name: {{ template "kube-prometheus-stack.fullname" . }} + name: {{ template "kube-prometheus-stack.prometheus.crname" . }} namespace: {{ template "kube-prometheus-stack.namespace" . }} labels: app: {{ template "kube-prometheus-stack.name" . }}-prometheus diff --git a/charts/kube-prometheus-stack/templates/prometheus/service.yaml b/charts/kube-prometheus-stack/templates/prometheus/service.yaml index 7318e58758d0..1e1f9c7b7f1a 100644 --- a/charts/kube-prometheus-stack/templates/prometheus/service.yaml +++ b/charts/kube-prometheus-stack/templates/prometheus/service.yaml @@ -56,7 +56,7 @@ spec: publishNotReadyAddresses: {{ .Values.prometheus.service.publishNotReadyAddresses }} selector: app.kubernetes.io/name: prometheus - prometheus: {{ template "kube-prometheus-stack.fullname" . }} + prometheus: {{ template "kube-prometheus-stack.prometheus.crname" . }} {{- if .Values.prometheus.service.sessionAffinity }} sessionAffinity: {{ .Values.prometheus.service.sessionAffinity }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecar.yaml b/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecar.yaml index b18a0fc5f1a7..2b80e7742fa0 100644 --- a/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecar.yaml +++ b/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecar.yaml @@ -35,5 +35,5 @@ spec: {{- end }} selector: app.kubernetes.io/name: prometheus - prometheus: {{ template "kube-prometheus-stack.fullname" . }} + prometheus: {{ template "kube-prometheus-stack.prometheus.crname" . }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecarExternal.yaml b/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecarExternal.yaml index 714f4e26f6bb..fa45934d7498 100644 --- a/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecarExternal.yaml +++ b/charts/kube-prometheus-stack/templates/prometheus/serviceThanosSidecarExternal.yaml @@ -42,5 +42,5 @@ spec: {{- end }} selector: app.kubernetes.io/name: prometheus - prometheus: {{ template "kube-prometheus-stack.fullname" . }} + prometheus: {{ template "kube-prometheus-stack.prometheus.crname" . }} {{- end }} diff --git a/charts/kube-prometheus-stack/templates/prometheus/serviceperreplica.yaml b/charts/kube-prometheus-stack/templates/prometheus/serviceperreplica.yaml index 34a4a91cc83a..8d2fdc33d753 100644 --- a/charts/kube-prometheus-stack/templates/prometheus/serviceperreplica.yaml +++ b/charts/kube-prometheus-stack/templates/prometheus/serviceperreplica.yaml @@ -42,8 +42,8 @@ items: targetPort: {{ $serviceValues.targetPort }} selector: app.kubernetes.io/name: prometheus - prometheus: {{ include "kube-prometheus-stack.fullname" $ }} - statefulset.kubernetes.io/pod-name: prometheus-{{ include "kube-prometheus-stack.fullname" $ }}-{{ $i }} + prometheus: {{ include "kube-prometheus-stack.prometheus.crname" $ }} + statefulset.kubernetes.io/pod-name: prometheus-{{ include "kube-prometheus-stack.prometheus.crname" $ }}-{{ $i }} type: "{{ $serviceValues.type }}" {{- end }} {{- end }} diff --git a/charts/kube-prometheus-stack/values.yaml b/charts/kube-prometheus-stack/values.yaml index 3a9b311a0f76..dba22fafe42d 100644 --- a/charts/kube-prometheus-stack/values.yaml +++ b/charts/kube-prometheus-stack/values.yaml @@ -2813,3 +2813,7 @@ prometheus: ## https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#podmetricsendpoint ## # podMetricsEndpoints: [] + +## Setting to true produces cleaner names, but may require a data migration because of persistent volume claim name change. +## +cleanPrometheusOperatorObjectNames: false