From c716c1795ee0c30a2a58146d7f0652289acb0e14 Mon Sep 17 00:00:00 2001 From: Maciej Moleda Date: Thu, 23 Jul 2020 01:58:59 +0100 Subject: [PATCH] [argocd-notifications] add monitoring and slack bot service annotations (#411) * feat: add slack bot service annotations to argocd-notifications * feat: add monitoring to argocd-notifications --- charts/argocd-notifications/Chart.yaml | 2 +- .../templates/_helpers.tpl | 21 +++++++++++++ .../templates/bots/slack/service.yaml | 4 +++ .../templates/deployment.yaml | 10 +++++++ .../templates/service-metrics.yaml | 15 ++++++++++ .../templates/servicemonitor.yaml | 30 +++++++++++++++++++ charts/argocd-notifications/values.yaml | 13 ++++++++ 7 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 charts/argocd-notifications/templates/service-metrics.yaml create mode 100644 charts/argocd-notifications/templates/servicemonitor.yaml diff --git a/charts/argocd-notifications/Chart.yaml b/charts/argocd-notifications/Chart.yaml index 64d77c9a..9954d4ca 100644 --- a/charts/argocd-notifications/Chart.yaml +++ b/charts/argocd-notifications/Chart.yaml @@ -3,7 +3,7 @@ appVersion: 0.7.0 description: A Helm chart for ArgoCD notifications, an add-on to ArgoCD. name: argocd-notifications type: application -version: 1.0.7 +version: 1.0.8 home: https://github.com/argoproj/argo-helm icon: https://raw.githubusercontent.com/argoproj/argo/master/docs/assets/argo.png keywords: diff --git a/charts/argocd-notifications/templates/_helpers.tpl b/charts/argocd-notifications/templates/_helpers.tpl index 18235d26..373c5495 100644 --- a/charts/argocd-notifications/templates/_helpers.tpl +++ b/charts/argocd-notifications/templates/_helpers.tpl @@ -43,6 +43,19 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} +{{/* +Common metrics labels +*/}} +{{- define "argocd-notifications.metrics.labels" -}} +helm.sh/chart: {{ include "argocd-notifications.chart" . }} +{{ include "argocd-notifications.metrics.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + + {{/* Common slack bot labels */}} @@ -63,6 +76,14 @@ app.kubernetes.io/name: {{ include "argocd-notifications.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end -}} +{{/* +Selector metrics labels +*/}} +{{- define "argocd-notifications.metrics.selectorLabels" -}} +app.kubernetes.io/name: {{ include "argocd-notifications.name" . }}-metrics +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + {{/* Selector slack bot labels */}} diff --git a/charts/argocd-notifications/templates/bots/slack/service.yaml b/charts/argocd-notifications/templates/bots/slack/service.yaml index 1878fe9d..68881a36 100644 --- a/charts/argocd-notifications/templates/bots/slack/service.yaml +++ b/charts/argocd-notifications/templates/bots/slack/service.yaml @@ -3,6 +3,10 @@ apiVersion: v1 kind: Service metadata: name: {{ include "argocd-notifications.name" . }}-bot + {{- if .Values.bots.slack.service.annotations }} + annotations: + {{- toYaml .Values.bots.slack.service.annotations | nindent 4 }} + {{- end }} spec: ports: - name: server diff --git a/charts/argocd-notifications/templates/deployment.yaml b/charts/argocd-notifications/templates/deployment.yaml index cbe71ca7..d9f53a25 100644 --- a/charts/argocd-notifications/templates/deployment.yaml +++ b/charts/argocd-notifications/templates/deployment.yaml @@ -29,6 +29,16 @@ spec: command: - /app/argocd-notifications - controller + - --loglevel={{ .Values.logLevel }} + {{- if .Values.metrics.enabled }} + - --metrics-port={{ .Values.metrics.port }} + {{- end }} + ports: + {{- if .Values.metrics.enabled }} + - containerPort: {{ .Values.metrics.port }} + name: metrics + protocol: TCP + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/argocd-notifications/templates/service-metrics.yaml b/charts/argocd-notifications/templates/service-metrics.yaml new file mode 100644 index 00000000..5645a4d3 --- /dev/null +++ b/charts/argocd-notifications/templates/service-metrics.yaml @@ -0,0 +1,15 @@ +{{- if .Values.metrics.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "argocd-notifications.name" . }}-metrics + labels: + {{- include "argocd-notifications.metrics.labels" . | nindent 4 }} +spec: + selector: + {{- include "argocd-notifications.selectorLabels" . | nindent 4 }} + ports: + - name: metrics + port: {{ .Values.metrics.port }} + targetPort: {{ .Values.metrics.port }} +{{- end }} diff --git a/charts/argocd-notifications/templates/servicemonitor.yaml b/charts/argocd-notifications/templates/servicemonitor.yaml new file mode 100644 index 00000000..b04851f3 --- /dev/null +++ b/charts/argocd-notifications/templates/servicemonitor.yaml @@ -0,0 +1,30 @@ +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "argocd-notifications.name" . }}-metrics + {{- if .Values.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.metrics.serviceMonitor.namespace }} + {{- end }} + labels: + {{- include "argocd-notifications.metrics.labels" . | nindent 4 }} + {{- if .Values.metrics.serviceMonitor.additionalLabels }} + {{- toYaml .Values.metrics.serviceMonitor.additionalLabels | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + path: /metrics + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "argocd-notifications.metrics.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/argocd-notifications/values.yaml b/charts/argocd-notifications/values.yaml index fe732362..3b9e03b7 100644 --- a/charts/argocd-notifications/values.yaml +++ b/charts/argocd-notifications/values.yaml @@ -87,6 +87,18 @@ secret: # email address in from field from: +logLevel: info + +metrics: + enabled: false + port: 9001 + serviceMonitor: + enabled: false + additionalLabels: {} + # namespace: monitoring + # interval: 30s + # scrapeTimeout: 10s + resources: {} # limits: # cpu: 100m @@ -194,6 +206,7 @@ bots: imagePullSecrets: [] service: + annotations: {} type: LoadBalancer serviceAccount: