Skip to content

Commit

Permalink
fix: add Prometheus scraping annotations only if serviceMonitor not c…
Browse files Browse the repository at this point in the history
…reated
  • Loading branch information
SebPlv authored Oct 17, 2023
1 parent d1a2770 commit 6b2268f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.metrics }}
{{- if .Values.metrics.prometheus }}
{{- if and (.Values.metrics.prometheus) (not .Values.metrics.prometheus.serviceMonitor) }}
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: {{ quote (index .Values.ports .Values.metrics.prometheus.entryPoint).port }}
Expand Down
9 changes: 9 additions & 0 deletions traefik/tests/pod-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,12 @@ tests:
- equal:
path: spec.template.spec.dnsConfig.options[1].name
value: "edns0"
- it: should not have prometheus annotations
set:
metrics:
prometheus:
serviceMonitor:
jobLabel: traefik
asserts:
- isNull:
path: spec.template.metadata.annotations.prometheus.io/scrape

0 comments on commit 6b2268f

Please sign in to comment.