Skip to content

Commit

Permalink
chore: support prometheus stack
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Sep 3, 2024
1 parent 7fafb1d commit 0451731
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
20 changes: 20 additions & 0 deletions addons-cluster/redis-cluster/templates/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if and (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") .Values.prometheus.enabled }}
# Prometheus Monitor Service (Metrics)
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "kblib.clusterName" . }}-metrics-monitor
labels:
{{- include "kblib.clusterLabels" . | nindent 4 }}
spec:
podMetricsEndpoints:
- path: /metrics
port: http-metrics
scheme: http
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "redis-cluster.selectorLabels" . | nindent 6 }}
{{- end }}
24 changes: 24 additions & 0 deletions addons-cluster/redis/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Define redis cluster shardingSpec with ComponentDefinition.
name: redis
componentDef: redis-cluster-7
replicas: {{ .Values.replicas }}
{{- include "redis-cluster.exporter" . | indent 4 }}
{{- if .Values.nodePortEnabled }}
services:
- name: redis-advertised
Expand Down Expand Up @@ -45,6 +46,7 @@ Define redis ComponentSpec with ComponentDefinition.
{{- define "redis-cluster.componentSpec" }}
- name: redis
{{- include "redis-cluster.replicaCount" . | indent 2 }}
{{- include "redis-cluster.exporter" . | indent 2 }}
{{- if .Values.nodePortEnabled }}
services:
- name: redis-advertised
Expand Down Expand Up @@ -125,3 +127,25 @@ Define redis cluster sharding count.
{{- define "redis-cluster.shards" }}
shards: {{ max .Values.redisCluster.shardCount 3 }}
{{- end }}


{{/*
Define redis cluster prometheus exporter.
*/}}
{{- define "redis-cluster.exporter" }}
{{- if or .Values.prometheus.enabled ( not .Values.extra.disableExporter ) }}
disableExporter: false
{{- else }}
disableExporter: true
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "redis-cluster.selectorLabels" -}}
{{- /*app.kubernetes.io/name: {{ include "kblib.clusterName" . | quote }}*/ -}}
app.kubernetes.io/instance: {{ include "kblib.clusterName" . | quote }}
app.kubernetes.io/managed-by: "kubeblocks"
apps.kubeblocks.io/component-name: "redis"
{{- end }}
3 changes: 3 additions & 0 deletions addons-cluster/redis/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ redisCluster:

extra:
rbacEnabled: true

prometheus:
enabled: false

0 comments on commit 0451731

Please sign in to comment.