Skip to content

Commit

Permalink
feat: [SMP-2324]: Add template function for podmonitors (#77)
Browse files Browse the repository at this point in the history
* feat: [SMP-2324]: Add template function for podmonitors

* default values
  • Loading branch information
Sarthak S authored Jan 11, 2024
1 parent 26354b9 commit 246f7fd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/common/templates/_monitoring.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,32 @@ prometheus.io/scrape: {{ $enabled | quote}}
protocol: "TCP"
{{- end }}
{{- end -}}
{{/* Podmonitor template to be added for Google Managed prometheus
{{ include "harnesscommon.monitoring.podMonitor" (dict "name" "ng-manager" "ctx" $ "label" "app.kubernetes.io/name") }}
*/}}
{{- define "harnesscommon.monitoring.podMonitor" -}}
{{- $ := .ctx }}
{{- $enabled := and $.Values.global.monitoring.enabled (eq $.Values.global.monitoring.managedPlatform "google") -}}
{{- $localMonitoring := default (dict) ((pluck "monitoring" $.Values) | first) -}}
{{- $globalMonitoring := default (dict) ((pluck "monitoring" $.Values.global) | first) -}}
{{- $monitoring := (mergeOverwrite $globalMonitoring $localMonitoring ) }}
{{- $port := (pluck "port" $monitoring) | first }}
{{- $path := (pluck "path" $monitoring) | first }}
{{- $namespace := $.Release.Namespace }}
{{- if $enabled -}}
apiVersion: monitoring.googleapis.com/v1
kind: PodMonitoring
metadata:
name: {{ $.Chart.Name }}
namespace: {{ $namespace }}
spec:
selector:
matchLabels:
{{ .label }}: {{ default $.Chart.Name .name }}
endpoints:
- port: {{ default "8889" $port | quote }}
interval: 120s
path: {{ default "/metrics" $path | quote }}
{{- end }}
{{- end -}}

0 comments on commit 246f7fd

Please sign in to comment.