Skip to content

Commit

Permalink
🐛 Don't fail when prometheus is disabled (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur authored Dec 7, 2022
1 parent 4d515ca commit f04bdd4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 5 additions & 2 deletions traefik/templates/service-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{{- fail "ERROR: Cannot create a metrics service when name contains more than 50 characters" }}
{{- end }}

{{- if .Values.metrics.prometheus }}
{{- if .Values.metrics.prometheus.service }}
{{- if (and (.Values.metrics.prometheus.service).enabled (not .Values.hub.enabled)) -}}
apiVersion: v1
kind: Service
Expand All @@ -26,5 +28,6 @@ spec:
{{- if .Values.ports.metrics.nodePort }}
nodePort: {{ .Values.ports.metrics.nodePort }}
{{- end }}
{{- end -}}

{{- end }}
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions traefik/tests/metrics-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ suite: Traefik Metrics configuration
templates:
- deployment.yaml
tests:
- it: "should support to set prometheus: null"
set:
metrics:
prometheus: null
asserts:
- hasDocuments:
count: 1
- it: should have prometheus enabled by default on metrics entrypoint
asserts:
- contains:
Expand Down
7 changes: 7 additions & 0 deletions traefik/tests/service-metrics-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ suite: Metrics Service configuration
templates:
- service-metrics.yaml
tests:
- it: "should support prometheus: null"
set:
metrics:
prometheus: null
asserts:
- hasDocuments:
count: 0
- it: should not provide a dedicated metrics service by default
asserts:
- hasDocuments:
Expand Down

0 comments on commit f04bdd4

Please sign in to comment.