diff --git a/charts/kyverno/Chart.yaml b/charts/kyverno/Chart.yaml index 7b89c5170a..e2714e6edf 100644 --- a/charts/kyverno/Chart.yaml +++ b/charts/kyverno/Chart.yaml @@ -26,6 +26,8 @@ annotations: url: https://kyverno.io/docs # valid kinds are: added, changed, deprecated, removed, fixed and security artifacthub.io/changes: | + - kind: changed + description: only create ServiceMonitor if cluster supports it - kind: fixed description: rbac templating issues - kind: added diff --git a/charts/kyverno/templates/admission-controller/servicemonitor.yaml b/charts/kyverno/templates/admission-controller/servicemonitor.yaml index d97ab2f385..25a203ab7c 100644 --- a/charts/kyverno/templates/admission-controller/servicemonitor.yaml +++ b/charts/kyverno/templates/admission-controller/servicemonitor.yaml @@ -1,4 +1,4 @@ -{{- if .Values.admissionController.serviceMonitor.enabled }} +{{- if and .Values.admissionController.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: diff --git a/charts/kyverno/templates/background-controller/servicemonitor.yaml b/charts/kyverno/templates/background-controller/servicemonitor.yaml index 67c38a22d6..5745ac307a 100644 --- a/charts/kyverno/templates/background-controller/servicemonitor.yaml +++ b/charts/kyverno/templates/background-controller/servicemonitor.yaml @@ -1,5 +1,5 @@ {{- if .Values.backgroundController.enabled -}} -{{- if .Values.backgroundController.serviceMonitor.enabled -}} +{{- if and .Values.backgroundController.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") -}} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: diff --git a/charts/kyverno/templates/cleanup-controller/servicemonitor.yaml b/charts/kyverno/templates/cleanup-controller/servicemonitor.yaml index e9f50e6347..a26eb643b9 100644 --- a/charts/kyverno/templates/cleanup-controller/servicemonitor.yaml +++ b/charts/kyverno/templates/cleanup-controller/servicemonitor.yaml @@ -1,5 +1,5 @@ {{- if .Values.cleanupController.enabled -}} -{{- if .Values.cleanupController.serviceMonitor.enabled -}} +{{- if and .Values.cleanupController.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") -}} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: diff --git a/charts/kyverno/templates/reports-controller/servicemonitor.yaml b/charts/kyverno/templates/reports-controller/servicemonitor.yaml index 681e3d9931..1f97b1ecb0 100644 --- a/charts/kyverno/templates/reports-controller/servicemonitor.yaml +++ b/charts/kyverno/templates/reports-controller/servicemonitor.yaml @@ -1,5 +1,5 @@ {{- if .Values.reportsController.enabled -}} -{{- if .Values.reportsController.serviceMonitor.enabled -}} +{{- if and .Values.reportsController.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") -}} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: