Skip to content

Commit

Permalink
Merge pull request #33 from intergral/cluster_label
Browse files Browse the repository at this point in the history
fix(monitoring): fix issue with cluster label
  • Loading branch information
Umaaz authored Oct 10, 2023
2 parents 1785839 + 0fbe93d commit 77705c8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/deep-distributed/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.18
version: 0.0.19

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
2 changes: 1 addition & 1 deletion charts/deep-distributed/templates/lib/service-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
targetLabel: job
{{- if kindIs "string" .clusterLabel }}
- replacement: "{{ include "deep.clusterName" $.ctx}}"
targetLabel: cluster
targetLabel: "{{ .clusterLabel }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/deep/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.7
version: 1.0.8

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 2 additions & 2 deletions charts/deep/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ spec:
replacement: "{{ include "deep.fullname" $ }}"
targetLabel: job
{{- if kindIs "string" .clusterLabel }}
- replacement: "{{ include "deep.clusterName" $.ctx}}"
targetLabel: cluster
- replacement: "{{ include "deep.clusterName" $ }}"
targetLabel: "{{ .clusterLabel }}"
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
Expand Down
46 changes: 46 additions & 0 deletions charts/deep/unittests/serviceMonitor_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
suite: test service monitor
chart:
version: 9.9.9+test
appVersion: 1.1.1+test
release:
name: deep
set:
monitoring:
enabled: true
serviceMonitor:
namespace: monitoring
labels:
release: prometheus
tests:
- it: should create correct servicemonitor
template: serviceMonitor.yaml
asserts:
- isKind:
of: ServiceMonitor
- matchRegex:
path: metadata.name
pattern: deep
- it: should have cluster label
template: serviceMonitor.yaml
asserts:
- equal:
path: spec.endpoints[0].relabelings[1].replacement
value: deep
- equal:
path: spec.endpoints[0].relabelings[1].targetLabel
value: cluster
- it: cluster label should use config
set:
config:
clusterName: "fromconfig"
monitoring:
serviceMonitor:
clusterLabel: "labelfromconfig"
template: serviceMonitor.yaml
asserts:
- equal:
path: spec.endpoints[0].relabelings[1].replacement
value: fromconfig
- equal:
path: spec.endpoints[0].relabelings[1].targetLabel
value: labelfromconfig

0 comments on commit 77705c8

Please sign in to comment.