diff --git a/deploy/charts/version-checker/README.md b/deploy/charts/version-checker/README.md index 04ae1beb..ecd849c2 100644 --- a/deploy/charts/version-checker/README.md +++ b/deploy/charts/version-checker/README.md @@ -71,7 +71,7 @@ A Helm chart for version-checker | service.labels | object | `{}` | Additional labels to add to the service | | service.port | int | `8080` | Port to expose within the service | | serviceMonitor.additionalLabels | object | `{}` | Additional labels to add to the ServiceMonitor | -| serviceMonitor.enabled | bool | `false` | Disable/Enable ServiceMonitor Object | +| serviceMonitor.enabled | bool | `true` | Disable/Enable ServiceMonitor Object | | tolerations | list | `[]` | Configure tolerations | | topologySpreadConstraints | list | `[]` | Set topologySpreadConstraints | | versionChecker.imageCacheTimeout | string | `"30m"` | How long to hold on to image tags and their versions | diff --git a/deploy/charts/version-checker/templates/servicemonitor.yaml b/deploy/charts/version-checker/templates/servicemonitor.yaml index d256c7fa..e9841d79 100644 --- a/deploy/charts/version-checker/templates/servicemonitor.yaml +++ b/deploy/charts/version-checker/templates/servicemonitor.yaml @@ -1,4 +1,4 @@ -{{- if or .Values.serviceMonitor.enabled }} +{{- if and .Values.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: diff --git a/deploy/charts/version-checker/tests/servicemonitor_test.yaml b/deploy/charts/version-checker/tests/servicemonitor_test.yaml index 237ddfe7..a91bc59c 100644 --- a/deploy/charts/version-checker/tests/servicemonitor_test.yaml +++ b/deploy/charts/version-checker/tests/servicemonitor_test.yaml @@ -1,15 +1,12 @@ suite: test ServiceMonitor templates: - servicemonitor.yaml +capabilities: + apiVersions: + - "monitoring.coreos.com/v1" + - "monitoring.coreos.com/v1/ServiceMonitor" tests: - - it: should work (defaults) - asserts: - - hasDocuments: - count: 0 - - - it: works (when enabled) - set: - serviceMonitor.enabled: true + - it: Should deploy (defaults) asserts: - hasDocuments: count: 1 @@ -18,7 +15,19 @@ tests: apiVersion: monitoring.coreos.com/v1 name: version-checker - - it: able to provide custom labels + - it: Not Deploy when disabled + capabilities: + apiVersions: [] + set: + serviceMonitor.enabled: false + asserts: + - hasDocuments: + count: 0 + + - it: Able to provide custom labels + capabilities: + apiVersions: + - "monitoring.coreos.com/v1/ServiceMonitor" set: serviceMonitor.enabled: true serviceMonitor.additionalLabels: diff --git a/deploy/charts/version-checker/values.yaml b/deploy/charts/version-checker/values.yaml index cdbc44c8..011b5e92 100644 --- a/deploy/charts/version-checker/values.yaml +++ b/deploy/charts/version-checker/values.yaml @@ -215,7 +215,7 @@ prometheus: # Configure a Prometheus-Operator ServiceMonitor object serviceMonitor: # -- Disable/Enable ServiceMonitor Object - enabled: false + enabled: true # -- Additional labels to add to the ServiceMonitor additionalLabels: {}