Skip to content

Commit b930665

Browse files
authored
Enable ServiceMonitor by default, if available (#320)
1 parent b795b6e commit b930665

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

deploy/charts/version-checker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ A Helm chart for version-checker
7171
| service.labels | object | `{}` | Additional labels to add to the service |
7272
| service.port | int | `8080` | Port to expose within the service |
7373
| serviceMonitor.additionalLabels | object | `{}` | Additional labels to add to the ServiceMonitor |
74-
| serviceMonitor.enabled | bool | `false` | Disable/Enable ServiceMonitor Object |
74+
| serviceMonitor.enabled | bool | `true` | Disable/Enable ServiceMonitor Object |
7575
| tolerations | list | `[]` | Configure tolerations |
7676
| topologySpreadConstraints | list | `[]` | Set topologySpreadConstraints |
7777
| versionChecker.imageCacheTimeout | string | `"30m"` | How long to hold on to image tags and their versions |

deploy/charts/version-checker/templates/servicemonitor.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if or .Values.serviceMonitor.enabled }}
1+
{{- if and .Values.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") }}
22
apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:

deploy/charts/version-checker/tests/servicemonitor_test.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
suite: test ServiceMonitor
22
templates:
33
- servicemonitor.yaml
4+
capabilities:
5+
apiVersions:
6+
- "monitoring.coreos.com/v1"
7+
- "monitoring.coreos.com/v1/ServiceMonitor"
48
tests:
5-
- it: should work (defaults)
6-
asserts:
7-
- hasDocuments:
8-
count: 0
9-
10-
- it: works (when enabled)
11-
set:
12-
serviceMonitor.enabled: true
9+
- it: Should deploy (defaults)
1310
asserts:
1411
- hasDocuments:
1512
count: 1
@@ -18,7 +15,19 @@ tests:
1815
apiVersion: monitoring.coreos.com/v1
1916
name: version-checker
2017

21-
- it: able to provide custom labels
18+
- it: Not Deploy when disabled
19+
capabilities:
20+
apiVersions: []
21+
set:
22+
serviceMonitor.enabled: false
23+
asserts:
24+
- hasDocuments:
25+
count: 0
26+
27+
- it: Able to provide custom labels
28+
capabilities:
29+
apiVersions:
30+
- "monitoring.coreos.com/v1/ServiceMonitor"
2231
set:
2332
serviceMonitor.enabled: true
2433
serviceMonitor.additionalLabels:

deploy/charts/version-checker/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ prometheus:
215215
# Configure a Prometheus-Operator ServiceMonitor object
216216
serviceMonitor:
217217
# -- Disable/Enable ServiceMonitor Object
218-
enabled: false
218+
enabled: true
219219
# -- Additional labels to add to the ServiceMonitor
220220
additionalLabels: {}
221221

0 commit comments

Comments
 (0)