feat(argo-cd): Add ability to scrape redis metrics (#892)

* feat(argo-cd): Add ability to scrape redis metrics

Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>

* Bump chart version

Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>
This commit is contained in:
Marco Kilchhofer 2021-09-17 19:47:11 +02:00 committed by GitHub
parent 489443e387
commit 7477b33cba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 144 additions and 2 deletions

View file

@ -64,6 +64,24 @@ spec:
{{- end }}
resources:
{{- toYaml .Values.redis.resources | nindent 10 }}
{{- if .Values.redis.metrics.enabled }}
- name: metrics
env:
- name: REDIS_ADDR
value: {{ printf "redis://localhost:%v" .Values.redis.containerPort }}
- name: REDIS_EXPORTER_WEB_LISTEN_ADDRESS
value: {{ printf "0.0.0.0:%v" .Values.redis.metrics.containerPort }}
image: {{ .Values.redis.metrics.image.repository }}:{{ .Values.redis.metrics.image.tag }}
imagePullPolicy: {{ .Values.redis.metrics.image.imagePullPolicy}}
ports:
- containerPort: {{ .Values.redis.metrics.containerPort }}
name: metrics
protocol: TCP
resources: {{- toYaml .Values.redis.metrics.resources | nindent 10 }}
{{- with .Values.redis.containerSecurityContext }}
securityContext: {{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- with .Values.redis.extraContainers }}
{{- toYaml . | nindent 6 }}
{{- end }}

View file

@ -0,0 +1,28 @@
{{- $redisHa := (index .Values "redis-ha") -}}
{{- if and .Values.redis.enabled (not $redisHa.enabled) .Values.redis.metrics.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "argo-cd.redis.fullname" . }}-metrics
{{- with .Values.redis.metrics.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "argo-cd.labels" (dict "context" . "component" .Values.redis.name "name" .Values.redis.name) | nindent 4 }}
{{- with .Values.redis.metrics.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.redis.metrics.service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
ports:
- name: {{ .Values.redis.metrics.service.portName }}
protocol: TCP
port: {{ .Values.redis.metrics.service.servicePort }}
targetPort: metrics
selector:
{{- include "argo-cd.selectorLabels" (dict "context" . "component" .Values.redis.name "name" .Values.redis.name) | nindent 4 }}
type: {{ .Values.redis.metrics.service.type }}
{{- end }}

View file

@ -21,6 +21,13 @@ spec:
ports:
- port: redis
protocol: TCP
{{- if .Values.redis.metrics.enabled }}
- from:
- namespaceSelector: {}
ports:
- port: metrics
protocol: TCP
{{- end }}
podSelector:
matchLabels:
{{- include "argo-cd.selectorLabels" (dict "context" . "name" .Values.redis.name) | nindent 6 }}

View file

@ -0,0 +1,39 @@
{{- $redisHa := (index .Values "redis-ha") -}}
{{- if and .Values.redis.enabled (not $redisHa.enabled) .Values.redis.metrics.enabled .Values.redis.metrics.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "argo-cd.redis.fullname" . }}
{{- with .Values.redis.metrics.serviceMonitor.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "argo-cd.labels" (dict "context" . "component" .Values.redis.name "name" .Values.redis.name) | nindent 4 }}
{{- with .Values.redis.metrics.serviceMonitor.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.redis.metrics.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: {{ .Values.redis.metrics.service.portName }}
{{- with .Values.redis.metrics.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
path: /metrics
{{- with .Values.redis.metrics.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.redis.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "argo-cd.selectorLabels" (dict "context" . "component" .Values.redis.name "name" .Values.redis.name) | nindent 6 }}
{{- end }}