From 5cd7f67c64e58d4fc6d202e5272c08bceff194d2 Mon Sep 17 00:00:00 2001 From: Alex Layton Date: Wed, 20 Jul 2022 16:30:21 -0400 Subject: [PATCH] feat(chart): add Prometheus monitors --- charts/oada/Chart.yaml | 4 ++-- charts/oada/templates/_helpers.tpl | 5 +++++ charts/oada/templates/deployment.yaml | 19 +++++++++++++++++++ charts/oada/values.yaml | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/charts/oada/Chart.yaml b/charts/oada/Chart.yaml index 67d30767..e8886e5e 100644 --- a/charts/oada/Chart.yaml +++ b/charts/oada/Chart.yaml @@ -8,8 +8,8 @@ maintainers: - name: awlayton email: alex@layton.in type: application -version: 1.2.4 -appVersion: '3.4.1' +version: 1.3.0 +appVersion: '3.4.4' annotations: artifacthub.io/recommendations: | - url: https://artifacthub.io/packages/helm/cert-manager/cert-manager diff --git a/charts/oada/templates/_helpers.tpl b/charts/oada/templates/_helpers.tpl index 6b779a6f..ee51f866 100644 --- a/charts/oada/templates/_helpers.tpl +++ b/charts/oada/templates/_helpers.tpl @@ -50,6 +50,11 @@ app.kubernetes.io/part-of: oada {{ .Values.kafka.brokers | join "," | default $brokers }} {{- end -}} +{{/* Whether add Prometheus monitors */}} +{{- define "oada.prometheus" -}} + {{ .Values.prometheus | default (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") }} +{{- end -}} + {{/* TLS secret */}} {{- define "oada.tls" -}} tls-{{ .Release.Name }} diff --git a/charts/oada/templates/deployment.yaml b/charts/oada/templates/deployment.yaml index cdf05e11..1bc5d8e2 100644 --- a/charts/oada/templates/deployment.yaml +++ b/charts/oada/templates/deployment.yaml @@ -136,5 +136,24 @@ spec: targetAverageUtilization: {{ $.Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} {{- end }} +{{- if eq (include "oada.prometheus" $) "true" }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + namespace: {{ $.Release.Namespace }} + name: {{ $name }} + labels: + app.kubernetes.io/name: {{ $k }} + app.kubernetes.io/instance: {{ $.Release.Name }} + {{- include "oada.chart.labels" $ | nindent 4 }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ $k }} + app.kubernetes.io/instance: {{ $.Release.Name }} + podMetricsEndpoints: + - port: prometheus +{{- end }} --- {{ end -}} \ No newline at end of file diff --git a/charts/oada/values.yaml b/charts/oada/values.yaml index 21dc1909..17c54f87 100644 --- a/charts/oada/values.yaml +++ b/charts/oada/values.yaml @@ -71,6 +71,9 @@ k8sWaitFor: image: groundnuty/k8s-wait-for tag: v1.6 +# prometheus is whether to add prometheus monitors for oada +prometheus: ~ + global: # global.development is whether to enable development/debug features not meant for production use development: false