Skip to content

Commit 9789f64

Browse files
authored
feat(kube-monitoring): ensure unique secret names based on the release (#662)
* feat(kube-monitoring): ensure unique secret names based on the release To enable multiple deployments in the same namespace. Signed-off-by: Richard Tief <richard.tief@sap.com> * chore(kube-monitoring): rename secret to prevent `spec.secrets[1]: Duplicate value` `Release.Name` and `Release.Namespace` can be the same. Signed-off-by: Richard Tief <richard.tief@sap.com> * chore(kube-monitoring): add dummy secret if alerts not enabled Signed-off-by: Richard Tief <richard.tief@sap.com> * chore(kube-monitoring): add dummy secret explanation --------- Signed-off-by: Richard Tief <richard.tief@sap.com>
1 parent f2143f3 commit 9789f64

File tree

7 files changed

+35
-13
lines changed

7 files changed

+35
-13
lines changed

kube-monitoring/charts/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ maintainers:
88
name: kube-monitoring
99
sources:
1010
- https://github.com/cloudoperators/greenhouse-extensions
11-
version: 0.24.0
11+
version: 0.24.1
1212
# prometheus-operator app version
1313
appVersion: v0.79.2
1414
keywords:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alerts:
2+
dummySecret: true

kube-monitoring/charts/templates/_alertmanager-config.yaml.tpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
scheme: https
33
{{- if and .Values.alerts.enabled .Values.alerts.alertmanagers.hosts }}
44
tls_config:
5-
cert_file: /etc/prometheus/secrets/tls-prometheus-alertmanager-auth/tls.crt
6-
key_file: /etc/prometheus/secrets/tls-prometheus-alertmanager-auth/tls.key
5+
{{- if and .Values.alerts.alertmanagers.tlsConfig.cert .Values.alerts.alertmanagers.tlsConfig.key }}
6+
cert_file: /etc/prometheus/secrets/tls-prometheus-{{ .Release.Name }}/tls.crt
7+
key_file: /etc/prometheus/secrets/tls-prometheus-{{ .Release.Name }}/tls.key
8+
{{- else }}
9+
cert_file: /etc/prometheus/secrets/tls-prometheus-{{ .Release.Namespace }}/tls.crt
10+
key_file: /etc/prometheus/secrets/tls-prometheus-{{ .Release.Namespace }}/tls.key
11+
{{- end }}
712
static_configs:
813
- targets:
914
{{ toYaml .Values.alerts.alertmanagers.hosts | indent 8 }}

kube-monitoring/charts/templates/alertmanager-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ apiVersion: v1
22
kind: Secret
33

44
metadata:
5-
name: kube-monitoring-alertmanager-config
5+
name: {{ .Release.Name }}-alertmanager-config
66
labels:
77
{{- include "kube-prometheus-stack.labels" . | indent 4 }}
88

99
data:
10-
config.yaml: {{ include (print $.Template.BasePath "/_alertmanager-config.yaml.tpl") . | b64enc }}
10+
config.yaml: {{ tpl (include (print $.Template.BasePath "/_alertmanager-config.yaml.tpl") .) . | b64enc }}
1111
relabelConfig.yaml: {{ include "kubeMonitoring.defaultRelabelConfig" . | b64enc }}

kube-monitoring/charts/templates/alertmanager-tls-secret.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ apiVersion: v1
22
kind: Secret
33
type: Opaque
44
metadata:
5-
name: tls-prometheus-alertmanager-auth
5+
name: tls-prometheus-{{ .Release.Name }}-cert
66
labels:
77
{{- include "kube-prometheus-stack.labels" . | indent 4 }}
88
data:
99
tls.crt: {{ .Values.alerts.alertmanagers.tlsConfig.cert | b64enc | quote }}
1010
tls.key: {{ .Values.alerts.alertmanagers.tlsConfig.key | b64enc | quote }}
1111

12+
{{- if .Values.alerts.dummySecret }}
13+
---
14+
apiVersion: v1
15+
kind: Secret
16+
type: Opaque
17+
metadata:
18+
name: tls-prometheus-{{ .Release.Namespace }}
19+
data:
20+
tls.crt: ""
21+
tls.key: ""
22+
{{- end }}

kube-monitoring/charts/values.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ kubeMonitoring:
262262
ingress:
263263
enabled: false
264264

265-
## By default, a ca-bundle is deployed to enable tls between Prometheus and Alertmanager
265+
## By default, the alerts plugin deploys a ca-bundle to enable tls between Prometheus and Alertmanager
266266
annotations:
267267
disco: "true"
268268
kubernetes.io/tls-acme: "true"
@@ -284,23 +284,24 @@ kubeMonitoring:
284284
## Expected values are the secret name and key
285285
## Cannot be used with additionalAlertManagerConfigs
286286
additionalAlertManagerConfigsSecret:
287-
name: kube-monitoring-alertmanager-config
287+
name: "{{ $.Release.Name }}-alertmanager-config"
288288
key: config.yaml
289289

290290
## If additional alert relabel configurations are already deployed in a single secret, or you want to manage
291291
## them separately from the helm deployment, you can use this section.
292292
## Expected values are the secret name and key
293293
## Cannot be used with additionalAlertRelabelConfigs
294294
additionalAlertRelabelConfigsSecret:
295-
name: kube-monitoring-alertmanager-config
295+
name: "{{ $.Release.Name }}-alertmanager-config"
296296
key: relabelConfig.yaml
297297

298298
## Secrets is a list of Secrets in the same namespace as the Prometheus object, which shall be mounted into the Prometheus Pods.
299299
## The Secrets are mounted into /etc/prometheus/secrets/. Secrets changes after initial creation of a Prometheus object are not
300300
## reflected in the running Pods. To change the secrets mounted into the Prometheus Pods, the object must be deleted and recreated
301301
## with the new list of secrets.
302302
secrets:
303-
- tls-prometheus-alertmanager-auth
303+
- "tls-prometheus-{{ .Release.Name }}-cert"
304+
- "tls-prometheus-{{ .Release.Namespace }}"
304305

305306
storageSpec:
306307
volumeClaimTemplate:
@@ -353,11 +354,14 @@ kubernetes-operations:
353354
- name: plugin
354355
value: "{{ $.Release.Name }}"
355356

356-
357+
## Configures Prometheus Alertmanager
357358
alerts:
358359
enabled: false
360+
# Creates a dummy Secret to ensure standalone testing
361+
dummySecret: false
359362
alertmanagers:
360363
hosts: []
364+
## Overrides tls certificate to authenticate with Alertmanager
361365
tlsConfig:
362366
cert: ""
363367
key: ""

kube-monitoring/plugindefinition.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ kind: PluginDefinition
66
metadata:
77
name: kube-monitoring
88
spec:
9-
version: 2.10.1
9+
version: 2.11.0
1010
displayName: Kubernetes monitoring
1111
description: Native deployment and management of Prometheus along with Kubernetes cluster monitoring components.
1212
docMarkDownUrl: https://raw.githubusercontent.com/cloudoperators/greenhouse-extensions/main/kube-monitoring/README.md
1313
icon: https://raw.githubusercontent.com/cloudoperators/greenhouse-extensions/main/kube-monitoring/logo.png
1414
helmChart:
1515
name: kube-monitoring
1616
repository: oci://ghcr.io/cloudoperators/greenhouse-extensions/charts
17-
version: 0.23.1
17+
version: 0.24.1
1818
options:
1919
- name: global.commonLabels
2020
description: Labels to add to all resources. This can be used to add a support group or service to all alerts.

0 commit comments

Comments
 (0)