From f88b780bf02e1a56e4c292f365f5ce243ed7a420 Mon Sep 17 00:00:00 2001 From: Eddie Torres Date: Fri, 7 Oct 2022 16:22:41 +0000 Subject: [PATCH] Add serviceMonitor.labels parameter Add serviceMonitor.forceEnable parameter Signed-off-by: Eddie Torres --- charts/aws-ebs-csi-driver/templates/metrics.yaml | 12 +++++++----- charts/aws-ebs-csi-driver/values.yaml | 8 +++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/charts/aws-ebs-csi-driver/templates/metrics.yaml b/charts/aws-ebs-csi-driver/templates/metrics.yaml index db4ac0d399..5d8a783d10 100644 --- a/charts/aws-ebs-csi-driver/templates/metrics.yaml +++ b/charts/aws-ebs-csi-driver/templates/metrics.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Service metadata: name: ebs-csi-controller - namespace: kube-system + namespace: {{ .Release.Namespace }} labels: app: ebs-csi-controller spec: @@ -16,22 +16,24 @@ spec: targetPort: 3301 type: ClusterIP --- -{{- if (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") -}} +{{- if or (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") (.Values.controller.serviceMonitor.forceEnable)}} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: ebs-csi-controller - namespace: kube-system + namespace: {{ .Release.Namespace }} labels: app: ebs-csi-controller - release: prometheus + {{- if .Values.controller.serviceMonitor.labels }} + {{- toYaml .Values.controller.serviceMonitor.labels | nindent 4 }} + {{- end }} spec: selector: matchLabels: app: ebs-csi-controller namespaceSelector: matchNames: - - kube-system + - {{ .Release.Namespace }} endpoints: - targetPort: 3301 path: /metrics diff --git a/charts/aws-ebs-csi-driver/values.yaml b/charts/aws-ebs-csi-driver/values.yaml index 047f3fc841..565ba20020 100644 --- a/charts/aws-ebs-csi-driver/values.yaml +++ b/charts/aws-ebs-csi-driver/values.yaml @@ -139,7 +139,13 @@ controller: # will run (example: `:8080` which corresponds to port 8080 on local host). # The default is empty string, which means metrics endpoint is disabled. # --- - enableMetrics: false + enableMetrics: true + serviceMonitor: + # Enables the ServiceMonitor resource even if the prometheus-operator CRDs are not installed + forceEnable: false + # Additional labels for ServiceMonitor object + labels: + release: prometheus # If set to true, AWS API call metrics will be exported to the following # TCP endpoint: "0.0.0.0:3301" # ---