Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for metrics in chart #924

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions charts/mercure/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ spec:
- name: http
containerPort: {{ .Values.service.targetPort }}
protocol: TCP
{{- if .Values.metrics.enabled }}
- name: metrics
containerPort: {{ .Values.metrics.port }}
protocol: TCP
{{- end }}
livenessProbe:
httpGet:
path: /healthz
Expand Down
24 changes: 24 additions & 0 deletions charts/mercure/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@ spec:
name: http
selector:
{{- include "mercure.selectorLabels" . | nindent 4 }}
---
{{- if .Values.metrics.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "mercure.fullname" . }}-metrics
labels:
{{- include "mercure.labels" . | nindent 4 }}
prometheus-operated: true
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}

spec:
type: ClusterIP
ports:
- port: {{ .Values.metrics.port }}
targetPort: metrics
protocol: TCP
name: metrics
selector:
{{- include "mercure.selectorLabels" . | nindent 4 }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/mercure/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "mercure.fullname" . }}-metrics
labels:
app.kubernetes.io/name: {{ include "mercure.name" . }}
spec:
selector:
matchLabels:
prometheus-operated: "true"
endpoints:
- port: metrics
interval: {{ .Values.metrics.interval }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/mercure/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ subscriberJwtAlg: HS256
# -- The license key for [the High Availability version](https://mercure.rocks/docs/hub/cluster) (not necessary is you use the FOSS version).
license: ""

metrics:
# -- Enable the metrics. You must also add the [metrics](https://caddyserver.com/docs/caddyfile/directives/metrics) in the `globalOptions` for Caddy server.
# servers {
# metrics
# }
# admin :9181
enabled: false
# -- The port to use for exposing the metrics.
port: 9181

serviceMonitor:
# -- Whether to create a ServiceMonitor for Prometheus Operator.
enabled: false
# -- The interval to use for the ServiceMonitor to scrape the metrics.
interval: 15s

# -- The number of replicas (pods) to launch, must be 1 unless you are using [the High Availability version](https://mercure.rocks/docs/hub/cluster).
replicaCount: 1

Expand Down
Loading