From 5eed79c2d229eda54eea8defb9f8c16ed0ef75ea Mon Sep 17 00:00:00 2001 From: Helen Tseng Date: Tue, 30 Aug 2022 16:17:44 +0800 Subject: [PATCH 1/2] support podMonitor --- simple/Chart.yaml | 2 +- simple/templates/podmonitor.yaml | 28 ++++++++++++++++++++++++++++ simple/values.yaml | 10 ++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 simple/templates/podmonitor.yaml diff --git a/simple/Chart.yaml b/simple/Chart.yaml index e285596..8bd4df8 100644 --- a/simple/Chart.yaml +++ b/simple/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 description: Helm chart with simple deployment/service template name: simple -version: 0.8.0 +version: 0.9.0 appVersion: 0.0.1 tillerVersion: ">=2.14.3" \ No newline at end of file diff --git a/simple/templates/podmonitor.yaml b/simple/templates/podmonitor.yaml new file mode 100644 index 0000000..cb48e31 --- /dev/null +++ b/simple/templates/podmonitor.yaml @@ -0,0 +1,28 @@ +{{- range $podMonitorName, $ref := .Values.podMonitors }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ $podMonitorName }} + labels: + release: prometheus-operator + {{- if hasKey $ref "labels" }} + {{- range $key, $value := $ref.labels }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + namespaceSelector: + matchNames: + {{- range $namespace := $ref.namespaceSelector }} + - {{ $namespace }} + {{- end }} + selector: + matchLabels: + {{- range $key, $value := $ref.selector.matchLabels }} + {{ $key }}: {{ $value | quote }} + {{- end }} + podMetricsEndpoints: + {{- range $ref.podMetricsEndpoints }} + - port: {{ .port | quote }} + {{- end }} +{{- end}} \ No newline at end of file diff --git a/simple/values.yaml b/simple/values.yaml index 5e24294..b2afdaa 100644 --- a/simple/values.yaml +++ b/simple/values.yaml @@ -220,6 +220,16 @@ externalSecrets: {} # endpoints: # - port: http # port name of the service expose +# podMonitors: +# mongodb-observer: +# namespaceSelector: +# - shoplytics +# selector: +# matchLabels: +# app: mongodb-observer # which service you want to match +# podMetricsEndpoints: +# - port: http # port name of the service expose + # Don’t combine ScaledObject with Horizontal Pod Autoscaler (HPA) # exmaple yaml please refer to example/example-keda.yaml # KEDA: From 385024ff59c6479f4862629d45f2135b36398e22 Mon Sep 17 00:00:00 2001 From: Helen Tseng Date: Tue, 30 Aug 2022 16:40:40 +0800 Subject: [PATCH 2/2] update for comment --- simple/templates/podmonitor.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/simple/templates/podmonitor.yaml b/simple/templates/podmonitor.yaml index cb48e31..e132772 100644 --- a/simple/templates/podmonitor.yaml +++ b/simple/templates/podmonitor.yaml @@ -21,8 +21,5 @@ spec: {{- range $key, $value := $ref.selector.matchLabels }} {{ $key }}: {{ $value | quote }} {{- end }} - podMetricsEndpoints: - {{- range $ref.podMetricsEndpoints }} - - port: {{ .port | quote }} - {{- end }} + podMetricsEndpoints: {{- toYaml $ref.podMetricsEndpoints | nindent 4 }} {{- end}} \ No newline at end of file