Skip to content

Commit 3835d65

Browse files
authored
feat: support proper scraping for prometheus setup (#15)
refactor: disable service monitors when using prometheus sub-chart
1 parent 5e5096d commit 3835d65

File tree

11 files changed

+280
-141
lines changed

11 files changed

+280
-141
lines changed

charts/conduit/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.16
18+
version: 0.2.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
@@ -29,6 +29,6 @@ dependencies:
2929
repository: https://grafana.github.io/helm-charts
3030
condition: loki.setup
3131
- name: prometheus
32-
version: 15.14.0
32+
version: 27.6.0
3333
repository: https://prometheus-community.github.io/helm-charts
3434
condition: prometheus.setup

charts/conduit/templates/core/service.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{ $moduleSettings := index .Values "module-settings" }}
12
apiVersion: v1
23
kind: Service
34
metadata:
@@ -8,10 +9,18 @@ metadata:
89
{{- if .Values.core.service.labels }}
910
{{- toYaml .Values.core.service.labels | nindent 4 }}
1011
{{- end }}
11-
{{- if .Values.core.service.annotations }}
1212
annotations:
13+
{{- if .Values.core.metrics.enabled }}
14+
{{- if .Values.prometheus.setup }}
15+
prometheus.io/scrape: "true"
16+
prometheus.io/port: "{{ default $moduleSettings.metrics.service.port .Values.core.metrics.service.port }}"
17+
prometheus.io/path: /metrics
18+
prometheus.io/scheme: http
19+
{{- end }}
20+
{{- end }}
21+
{{- if .Values.core.service.annotations }}
1322
{{- toYaml .Values.core.service.annotations | nindent 4 }}
14-
{{- end }}
23+
{{- end }}
1524
spec:
1625
selector:
1726
{{ include "conduit-helm.selectorLabels" . | indent 4 }}
@@ -42,4 +51,4 @@ spec:
4251
{{- if .Values.core.service.loadBalancerIP }}
4352
loadBalancerIP: {{ .Values.core.service.loadBalancerIP | quote }}
4453
{{- end }}
45-
{{- end }}
54+
{{- end }}

charts/conduit/templates/core/servicemonitor.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{{- $coreName := include "conduit-helm.core.fullname" . -}}
22
{{- if .Values.core.metrics.enabled }}
3+
{{- if or .Values.global.enableServiceMonitors .Values.core.metrics.serviceMonitor.enabled }}
34
apiVersion: monitoring.coreos.com/v1
45
kind: ServiceMonitor
56
metadata:
@@ -47,3 +48,4 @@ spec:
4748
{{- toYaml . | nindent 8 }}
4849
{{- end }}
4950
{{- end }}
51+
{{- end }}

charts/conduit/templates/database/service.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{ $moduleSettings := index .Values "module-settings" }}
12
apiVersion: v1
23
kind: Service
34
metadata:
@@ -8,10 +9,18 @@ metadata:
89
{{- if .Values.database.service.labels }}
910
{{- toYaml .Values.database.service.labels | nindent 4 }}
1011
{{- end }}
11-
{{- if .Values.database.service.annotations }}
1212
annotations:
13+
{{- if .Values.database.metrics.enabled }}
14+
{{- if .Values.prometheus.setup }}
15+
prometheus.io/scrape: "true"
16+
prometheus.io/port: "{{ default $moduleSettings.metrics.service.port .Values.database.metrics.service.port }}"
17+
prometheus.io/path: /metrics
18+
prometheus.io/scheme: http
19+
{{- end }}
20+
{{- end }}
21+
{{- if .Values.database.service.annotations }}
1322
{{- toYaml .Values.database.service.annotations | nindent 4 }}
14-
{{- end }}
23+
{{- end }}
1524
spec:
1625
selector:
1726
{{ include "conduit-helm.selectorLabels" . | indent 4 }}

charts/conduit/templates/database/servicemonitor.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{{- $databaseName := include "conduit-helm.database.fullname" . -}}
22
{{- if .Values.database.metrics.enabled }}
3+
{{- if or .Values.global.enableServiceMonitors .Values.database.metrics.serviceMonitor.enabled }}
4+
35
apiVersion: monitoring.coreos.com/v1
46
kind: ServiceMonitor
57
metadata:
@@ -24,7 +26,7 @@ spec:
2426
app: {{ $databaseName }}
2527
namespaceSelector:
2628
matchNames:
27-
- {{ .Release.Namespace }}
29+
- {{ .Release.Namespace }}
2830
endpoints:
2931
- port: {{ .Values.database.metrics.service.name }}
3032
path: /metrics
@@ -47,3 +49,4 @@ spec:
4749
{{- toYaml . | nindent 8 }}
4850
{{- end }}
4951
{{- end }}
52+
{{- end }}

charts/conduit/templates/router/service.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{{- if .Values.router.enabled }}
2+
{{ $moduleSettings := index .Values "module-settings" }}
3+
24
apiVersion: v1
35
kind: Service
46
metadata:
@@ -9,10 +11,18 @@ metadata:
911
{{- if .Values.router.service.labels }}
1012
{{- toYaml .Values.router.service.labels | nindent 4 }}
1113
{{- end }}
12-
{{- if .Values.router.service.annotations }}
1314
annotations:
15+
{{- if .Values.router.metrics.enabled }}
16+
{{- if .Values.prometheus.setup }}
17+
prometheus.io/scrape: "true"
18+
prometheus.io/port: "{{ default $moduleSettings.metrics.service.port .Values.router.metrics.service.port }}"
19+
prometheus.io/path: /metrics
20+
prometheus.io/scheme: http
21+
{{- end }}
22+
{{- end }}
23+
{{- if .Values.router.service.annotations }}
1424
{{- toYaml .Values.router.service.annotations | nindent 4 }}
15-
{{- end }}
25+
{{- end }}
1626
spec:
1727
selector:
1828
{{ include "conduit-helm.selectorLabels" . | indent 4 }}
@@ -44,4 +54,4 @@ spec:
4454
loadBalancerIP: {{ .Values.router.service.loadBalancerIP | quote }}
4555
{{- end }}
4656
{{- end }}
47-
{{- end }}
57+
{{- end }}

charts/conduit/templates/router/servicemonitor.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{{- $routerName := include "conduit-helm.router.fullname" . -}}
22
{{- if and .Values.router.enabled .Values.router.metrics.enabled }}
3+
{{- if or .Values.global.enableServiceMonitors .Values.router.metrics.serviceMonitor.enabled }}
4+
35
apiVersion: monitoring.coreos.com/v1
46
kind: ServiceMonitor
57
metadata:
@@ -47,3 +49,4 @@ spec:
4749
{{- toYaml . | nindent 8 }}
4850
{{- end }}
4951
{{- end }}
52+
{{- end }}

charts/conduit/templates/services/service.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
apiVersion: v1
99
kind: Service
1010
metadata:
11-
name: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
11+
name: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
1212
labels:
1313
{{ include "conduit-helm.labels" $ | indent 4 }}
14-
app: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
14+
app: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
1515
{{- if $moduleSettings.service.labels }}
1616
{{- toYaml $moduleSettings.service.labels | nindent 4 }}
1717
{{- end }}
@@ -29,14 +29,22 @@ metadata:
2929
{{- toYaml $spec.service.annotations | nindent 4 }}
3030
{{- end }}
3131
{{- end }}
32+
{{- if $spec.metrics.enabled }}
33+
{{- if $.Values.prometheus.setup }}
34+
prometheus.io/scrape: "true"
35+
prometheus.io/port: "{{ default $moduleSettings.metrics.service.port $specMetricsService.port }}"
36+
prometheus.io/path: /metrics
37+
prometheus.io/scheme: http
38+
{{- end }}
39+
{{- end }}
3240
spec:
3341
selector:
3442
{{ include "conduit-helm.selectorLabels" $ | indent 4 }}
3543
app: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
3644
ports:
3745
- protocol: TCP
38-
port: {{ default $moduleSettings.service.tcp_port $specService.tcp_port }}
39-
name: tcp
46+
port: {{ default $moduleSettings.service.tcp_port $specService.tcp_port }}
47+
name: tcp
4048
targetPort: {{ default $.Values.global.config.grpc_port $moduleSettings.containerPort $specService.grpc_port }}
4149
{{- if $spec.metrics.enabled }}
4250
- port: {{ default $moduleSettings.metrics.service.port $specMetricsService.port }}
@@ -45,4 +53,4 @@ spec:
4553
{{- end }}
4654
type: ClusterIP
4755
{{- end }}
48-
{{- end }}
56+
{{- end }}

charts/conduit/templates/services/servicemonitor.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{{ $moduleSettings := index .Values "module-settings" }}
2+
{{ $moduleSettingsMonitor := $moduleSettings.metrics.serviceMonitor.enabled}}
23
{{- range $module, $spec := .Values.install -}}
34
{{- $specMetrics := $spec.metrics -}}
45
{{- $specMetricsService := $specMetrics.service -}}
56
{{- $specServiceMonitor := $specMetrics.serviceMonitor -}}
67
{{- if and $spec.enabled $spec.metrics.enabled }}
8+
{{- if or $.Values.global.enableServiceMonitors $specServiceMonitor $moduleSettingsMonitor }}
79
---
810
apiVersion: monitoring.coreos.com/v1
911
kind: ServiceMonitor
@@ -16,7 +18,7 @@ metadata:
1618
{{- end }}
1719
labels:
1820
{{ include "conduit-helm.labels" $ | indent 4 }}
19-
app: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
21+
app: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
2022
release: {{ template "conduit-helm.fullname" $ }}
2123
{{- if $moduleSettings.metrics.serviceMonitor.selector }}
2224
{{- toYaml $moduleSettings.metrics.serviceMonitor.selector | nindent 4 }}
@@ -34,7 +36,7 @@ spec:
3436
selector:
3537
matchLabels:
3638
{{ include "conduit-helm.selectorLabels" $ | indent 6 }}
37-
app: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
39+
app: {{ template "conduit-helm.fullname" $ }}-{{ $module }}
3840
namespaceSelector:
3941
matchNames:
4042
- {{ $.Release.Namespace }}
@@ -73,4 +75,5 @@ spec:
7375
{{- toYaml $moduleSettings.metrics.serviceMonitor.tlsConfig | nindent 8 }}
7476
{{- end }}
7577
{{- end }}
76-
{{- end }}
78+
{{- end }}
79+
{{- end }}

charts/conduit/values.dev.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# -- Provide a name in place of `conduit`
2+
nameOverride: "conduit"
3+
# -- String to fully override `"conduit-helm.fullname"`
4+
5+
global:
6+
image:
7+
# -- Global repository option
8+
repository: ghcr.io/conduitplatform
9+
# -- Overrides the global Conduit image tag whose default is the chart appVersion
10+
tag: dev
11+
imagePullPolicy: Always
12+
enableServiceMonitors: false
13+
install:
14+
sms:
15+
enabled: false
16+
forms:
17+
enabled: false
18+
authentication:
19+
enabled: true
20+
authorization:
21+
enabled: true
22+
chat:
23+
enabled: false
24+
notification:
25+
enabled: false
26+
email:
27+
enabled: false
28+
storage:
29+
enabled: false
30+
module-settings:
31+
# -- Resource limits and requests
32+
resources:
33+
requests:
34+
memory: "150Mi"
35+
cpu: "0"
36+
limits:
37+
memory: "500Mi"
38+
cpu: "1000m"
39+
# -- Admin Panel module
40+
admin:
41+
image:
42+
repository: ghcr.io/conduitplatform
43+
tag: dev
44+
imagePullPolicy: Always
45+
46+
# -- Enable an ingress resource for the Admin Panel
47+
ingress:
48+
enabled: true
49+
# -- Hostnames must be provided if Ingress is enabled.
50+
hostName: "admin.conduit"
51+
52+
53+
# -- Core module
54+
core:
55+
# -- Enable an ingress resource for the Core
56+
ingress:
57+
enabled: true
58+
# -- Hostnames must be provided if Ingress is enabled.
59+
hostName: "admin-api.conduit"
60+
61+
# -- Router module
62+
router:
63+
# -- Enable an ingress resource for the Router
64+
ingress:
65+
enabled: true
66+
67+
# -- Hostnames must be provided if Ingress is enabled.
68+
hostName: "router.conduit"
69+
70+
mongodb:
71+
enabled: true
72+
73+
loki:
74+
setup: true
75+
76+
prometheus:
77+
setup: true
78+
alertmanager:
79+
enabled: false
80+
kube-state-metrics:
81+
enabled: true
82+
prometheus-node-exporter:
83+
enabled: true
84+
prometheus-pushgateway:
85+
enabled: false

0 commit comments

Comments
 (0)