Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release namespace for Prometheus Operator resources #967

Merged
merged 6 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions traefik/templates/prometheusrules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "traefik.fullname" . }}
{{- if .Values.metrics.prometheus.prometheusRule.namespace }}
namespace: {{ .Values.metrics.prometheus.prometheusRule.namespace }}
{{- end }}
namespace: {{ .Values.metrics.prometheus.prometheusRule.namespace | default (include "traefik.namespace" .) }}
labels:
{{- include "traefik.labels" . | nindent 4 }}
{{- with .Values.metrics.prometheus.prometheusRule.additionalLabels }}
Expand Down
4 changes: 1 addition & 3 deletions traefik/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "traefik.fullname" . }}
{{- with .Values.metrics.prometheus.serviceMonitor.namespace }}
namespace: {{ . }}
{{- end }}
namespace: {{ .Values.metrics.prometheus.serviceMonitor.namespace | default (include "traefik.namespace" .) }}
labels:
{{- if (.Values.metrics.prometheus.service).enabled }}
{{- include "traefik.metricsservicelabels" . | nindent 4 }}
Expand Down
33 changes: 33 additions & 0 deletions traefik/tests/prometheusrules-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,36 @@ tests:
labels:
context: traefik
severity: warning
- it: should use the release namespace by default if metrics.prometheus.prometheusRule.namespace is not set
capabilities:
apiVersions:
- monitoring.coreos.com/v1
values:
- ./values/prometheusrules.yaml
release:
namespace: release-namespace
set:
metrics:
prometheus:
prometheusRule:
namespace: ""
asserts:
- hasDocuments:
count: 1
- equal:
path: metadata.namespace
value: release-namespace
- it: should use the release namespace if specified
capabilities:
apiVersions:
- monitoring.coreos.com/v1
values:
- ./values/prometheusrules.yaml
release:
namespace: release-namespace
asserts:
- hasDocuments:
count: 1
- equal:
path: metadata.namespace
value: another-namespace
33 changes: 33 additions & 0 deletions traefik/tests/servicemonitor-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,36 @@ tests:
- equal:
path: spec.selector.matchLabels["app.kubernetes.io/component"]
value: metrics
- it: should use the release namespace by default if metrics.prometheus.serviceMonitor.namespace is not set
capabilities:
apiVersions:
- monitoring.coreos.com/v1
values:
- ./values/servicemonitor.yaml
release:
namespace: release-namespace
set:
metrics:
prometheus:
serviceMonitor:
namespace: ""
asserts:
- hasDocuments:
count: 1
- equal:
path: metadata.namespace
value: release-namespace
- it: should use the release namespace if specified
capabilities:
apiVersions:
- monitoring.coreos.com/v1
values:
- ./values/servicemonitor.yaml
release:
namespace: release-namespace
asserts:
- hasDocuments:
count: 1
- equal:
path: metadata.namespace
value: another-namespace