From d12f5e70dbfc4314c0bf02d5f38ab1f381fb6736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 13 Aug 2024 15:48:21 +0200 Subject: [PATCH] Be able to have more that one PodMonitor endpoint on a pod --- templates/podmonitor.yaml | 4 ++-- tests/expected.yaml | 6 ++++-- tests/values.yaml | 11 +++++++---- values.md | 3 ++- values.schema.json | 8 ++++++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/templates/podmonitor.yaml b/templates/podmonitor.yaml index d226285..585a56a 100644 --- a/templates/podmonitor.yaml +++ b/templates/podmonitor.yaml @@ -16,9 +16,9 @@ metadata: spec: selector: matchLabels: {{- include "common.selectorLabels" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }} - {{- with $serviceDefinition.podMonitor.endpoint }} + {{- with $serviceDefinition.podMonitor.podMetricsEndpoints }} podMetricsEndpoints: - - {{ . | toYaml | nindent 6 }} + {{- include "common.dictToList" ( dict "keyName" "port" "contents" . ) | nindent 4 }} {{- end }} {{- end }} {{- end }} diff --git a/tests/expected.yaml b/tests/expected.yaml index b7459e7..d5dfb89 100644 --- a/tests/expected.yaml +++ b/tests/expected.yaml @@ -1544,7 +1544,9 @@ spec: app.kubernetes.io/instance: custom app.kubernetes.io/component: with-service-name podMetricsEndpoints: - - + - port: config-prometheus + honorLabels: true + interval: 10s + - port: prometheus honorLabels: true interval: 10s - port: prometheus diff --git a/tests/values.yaml b/tests/values.yaml index a074a8b..f7e4bc9 100644 --- a/tests/values.yaml +++ b/tests/values.yaml @@ -131,10 +131,13 @@ services: path: /one podMonitor: enabled: true - endpoint: - port: prometheus - interval: 10s - honorLabels: true + podMetricsEndpoints: + prometheus: + interval: 10s + honorLabels: true + config-prometheus: + interval: 10s + honorLabels: true replicaCount: 1 nodeSelector: {} affinity: diff --git a/values.md b/values.md index fa6debb..7db8f7b 100644 --- a/values.md +++ b/values.md @@ -210,7 +210,8 @@ - **`ports`** _(array)_ - **`podMonitor`** _(object)_: The Prometheus Pod monitor configuration. Cannot contain additional properties. - **`enabled`** _(boolean)_: Enable the Pod monitor for this service. - - **`endpoint`** _(object)_: The endpoint of the Pod monitor. + - **`podMetricsEndpoints`** _(object)_: The endpoints of the Pod monitor by port. Can contain additional properties. + - **Additional properties** _(object)_: The endpoint of the Pod monitor. ## Definitions diff --git a/values.schema.json b/values.schema.json index 6b99988..2670d9e 100644 --- a/values.schema.json +++ b/values.schema.json @@ -1083,9 +1083,13 @@ "type": "boolean", "description": "Enable the Pod monitor for this service" }, - "endpoint": { + "podMetricsEndpoints": { "type": "object", - "description": "The endpoint of the Pod monitor" + "description": "The endpoints of the Pod monitor by port", + "additionalProperties": { + "type": "object", + "description": "The endpoint of the Pod monitor" + } } } }