From 824391321f9fd98400f1c4d8e10bf3f47fa8ad91 Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Tue, 24 Dec 2019 12:49:00 +0900 Subject: [PATCH] Add PodMonitor template to flagger chart --- charts/flagger/README.md | 4 ++++ charts/flagger/templates/podmonitor.yaml | 27 ++++++++++++++++++++++++ charts/flagger/values.yaml | 6 ++++++ 3 files changed, 37 insertions(+) create mode 100644 charts/flagger/templates/podmonitor.yaml diff --git a/charts/flagger/README.md b/charts/flagger/README.md index 50aea9932..eb64b943b 100644 --- a/charts/flagger/README.md +++ b/charts/flagger/README.md @@ -84,6 +84,10 @@ Parameter | Description | Default `slack.channel` | Slack channel | None `slack.user` | Slack username | `flagger` `msteams.url` | Microsoft Teams incoming webhook | None +`podMonitor.enabled` | if `true`, create a PodMonitor for [monitoring the metrics](https://docs.flagger.app/usage/monitoring#metrics) | `false` +`podMonitor.namespace` | the namespace where the PodMonitor is created | the same namespace +`podMonitor.interval` | interval at which metrics should be scraped | `15s` +`podMonitor.podMonitor` | additional labels to add to the PodMonitor | `{}` `leaderElection.enabled` | leader election must be enabled when running more than one replica | `false` `leaderElection.replicaCount` | number of replicas | `1` `ingressAnnotationsPrefix` | annotations prefix for ingresses | `custom.ingress.kubernetes.io` diff --git a/charts/flagger/templates/podmonitor.yaml b/charts/flagger/templates/podmonitor.yaml new file mode 100644 index 000000000..fafca0319 --- /dev/null +++ b/charts/flagger/templates/podmonitor.yaml @@ -0,0 +1,27 @@ +{{- if .Values.podMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + labels: + helm.sh/chart: {{ template "flagger.chart" . }} + app.kubernetes.io/name: {{ template "flagger.name" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + {{- range $k, $v := .Values.podMonitor.additionalLabels }} + {{ $k }}: {{ $v | quote }} + {{- end }} + name: {{ include "flagger.fullname" . }} + namespace: {{ .Values.podMonitor.namespace | default .Release.Namespace }} +spec: + podMetricsEndpoints: + - interval: {{ .Values.podMonitor.interval }} + path: /metrics + port: http + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app.kubernetes.io/name: {{ template "flagger.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/flagger/values.yaml b/charts/flagger/values.yaml index ecf142ed1..0def888dc 100644 --- a/charts/flagger/values.yaml +++ b/charts/flagger/values.yaml @@ -33,6 +33,12 @@ msteams: # MS Teams incoming webhook URL url: +podMonitor: + enabled: false + namespace: + interval: 15s + additionalLabels: {} + #env: #- name: SLACK_URL # valueFrom: