Skip to content

Commit

Permalink
feat(helm): allow to set labels and annotations for podMonitor (#471)
Browse files Browse the repository at this point in the history
This PR adds the ability to set labels and annotations to the
podMonitor. Setting the label is usually necessary for the podMonitor to
be picked up by the Prometheus Operator
(prometheus-operator/prometheus-operator#3636 (comment)).
Setting an annotation helps to defer the deployment of the custom
resource if e.g. deploying with ArgoCD
(https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#skip-dry-run-for-new-custom-resources-types).
  • Loading branch information
pitwegner authored Jul 18, 2023
1 parent 061c410 commit 5dad655
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chart/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ kind: PodMonitor
metadata:
name: {{ include "hcloud-cloud-controller-manager.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- with $.Values.monitoring.podMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- range $key, $value := .Values.monitoring.podMonitor.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- tpl (toYaml $.Values.monitoring.podMonitor.spec) $ | nindent 2 }}
selector:
Expand Down
6 changes: 6 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ monitoring:
# When enabled (and metrics.enabled=true), a PodMonitor will be deployed to scrape metrics.
# The PodMonitor [1] CRD must already exist in the target cluster.
enabled: false
# PodMonitor Labels
labels: {}
# release: kube-prometheus-stack
# PodMonitor Annotations
annotations: {}
# PodMonitorSpec to be deployed. The "selector" field is set elsewhere and should *not* be used here.
# https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.PodMonitorSpec
spec:
podMetricsEndpoints:
- port: metrics


nameOverride: ~

Expand Down

0 comments on commit 5dad655

Please sign in to comment.