diff --git a/templates/podmonitor.yaml b/templates/podmonitor.yaml index 585a56a..8b685eb 100644 --- a/templates/podmonitor.yaml +++ b/templates/podmonitor.yaml @@ -5,13 +5,13 @@ apiVersion: monitoring.coreos.com/v1 kind: PodMonitor metadata: -{{- if hasKey $serviceDefinition.service "name" }} - name: {{ $serviceDefinition.service.name }} +{{- if hasKey $serviceDefinition.podMonitor "name" }} + name: {{ $serviceDefinition.podMonitor.name }} {{- else }} name: {{ include "common.fullname" ( dict "root" $ "service" $serviceDefinition "serviceName" $serviceName ) }} {{- end }} {{- $svcDict := deepCopy $serviceDefinition }} -{{- $svcDict := merge $svcDict (dict "annotations" $serviceDefinition.service.annotations "labels" $serviceDefinition.service.labels) }} +{{- $svcDict := merge $svcDict (dict "annotations" $serviceDefinition.podMonitor.annotations "labels" $serviceDefinition.podMonitor.labels) }} {{- include "common.metadata" ( dict "root" $ "service" $svcDict "serviceName" $serviceName ) | nindent 2 }} spec: selector: diff --git a/tests/expected.yaml b/tests/expected.yaml index 0a2a3d9..9b7e015 100644 --- a/tests/expected.yaml +++ b/tests/expected.yaml @@ -1550,3 +1550,26 @@ spec: - port: prometheus honorLabels: true interval: 10s +--- +# Source: custom-pod/templates/podmonitor.yaml +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: custom-custom-pod-example4 + labels: + helm.sh/chart: custom-pod + app.kubernetes.io/version: "1.0" + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: custom-pod + app.kubernetes.io/instance: custom + app.kubernetes.io/component: example4 +spec: + selector: + matchLabels: + app.kubernetes.io/name: custom-pod + app.kubernetes.io/instance: custom + app.kubernetes.io/component: example4 + podMetricsEndpoints: + - port: prometheus + honorLabels: true + interval: 10s diff --git a/tests/values.yaml b/tests/values.yaml index f7e4bc9..6897d87 100644 --- a/tests/values.yaml +++ b/tests/values.yaml @@ -139,7 +139,6 @@ services: interval: 10s honorLabels: true replicaCount: 1 - nodeSelector: {} affinity: podAntiAffinity: topologyKey: kubernetes.io/hostname @@ -368,7 +367,7 @@ services: <<: *servicedefinition name: hardcoded-service-name - # Eyample with labelSelector in affinity + # Example with labelSelector in affinity example4: enabled: true affinity: @@ -382,6 +381,13 @@ services: repository: camptocamp/image tag: latest + podMonitor: + enabled: true + podMetricsEndpoints: + prometheus: + interval: 10s + honorLabels: true + # Minimal configuration of a deployment deployment-min: enabled: true diff --git a/values.md b/values.md index b35b681..cc08192 100644 --- a/values.md +++ b/values.md @@ -211,7 +211,10 @@ - **`annotations`**: Refer to _[#/definitions/annotations](#definitions/annotations)_. - **`ports`** _(array)_ - **`podMonitor`** _(object)_: The Prometheus Pod monitor configuration. Cannot contain additional properties. - - **`enabled`** _(boolean)_: Enable the Pod monitor for this service. + - **`enabled`** _(boolean)_: Enable the Pod monitor for this service (Pod). + - **`name`** _(string)_: The name of the Pod monitor. + - **`labels`**: Refer to _[#/definitions/labels](#definitions/labels)_. + - **`annotations`**: Refer to _[#/definitions/annotations](#definitions/annotations)_. - **`podMetricsEndpoints`** _(object)_: The endpoints of the Pod monitor by port. Can contain additional properties. - **Additional properties** _(object)_: The endpoint of the Pod monitor. diff --git a/values.schema.json b/values.schema.json index 26f8fdb..ae58ce7 100644 --- a/values.schema.json +++ b/values.schema.json @@ -1089,7 +1089,17 @@ "properties": { "enabled": { "type": "boolean", - "description": "Enable the Pod monitor for this service" + "description": "Enable the Pod monitor for this service (Pod)" + }, + "name": { + "type": "string", + "description": "The name of the Pod monitor" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "annotations": { + "$ref": "#/definitions/annotations" }, "podMetricsEndpoints": { "type": "object",