Skip to content

Commit

Permalink
feat: allow to use prometheus credentials from helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
holzgeist committed Oct 8, 2024
1 parent 342fe18 commit 8d6b2d1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 6 deletions.
16 changes: 16 additions & 0 deletions livekit-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,19 @@ Create the name of the service monitor to use
{{- default "default" .Values.serviceMonitor.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the service monitor secret to use
*/}}
{{- define "livekit-server.serviceMonitorSecretName" -}}
{{- default (print (include "livekit-server.fullname" .) "-service-monitor-secret") .Values.serviceMonitor.secretName }}
{{- end }}

{{/*
Load prometheus port from old or new config
*/}}
{{- define "livekit-server.prometheus_port" -}}
{{- if or .Values.livekit.prometheus_port (and .Values.livekit.prometheus .Values.livekit.prometheus.port) }}
{{- default .Values.livekit.prometheus_port .Values.livekit.prometheus.port }}
{{- end }}
{{- end }}
6 changes: 3 additions & 3 deletions livekit-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ spec:
hostPort: {{ .Values.livekit.rtc.tcp_port }}
protocol: TCP
{{- end }}
{{- if .Values.livekit.prometheus_port }}
{{- if (include "livekit-server.prometheus_port" .) }}
- name: metrics
containerPort: {{ .Values.livekit.prometheus_port }}
hostPort: {{ .Values.livekit.prometheus_port }}
containerPort: {{ include "livekit-server.prometheus_port" . }}
hostPort: {{ include "livekit-server.prometheus_port" . }}
protocol: TCP
{{- end }}
{{- if .Values.livekit.turn.enabled }}
Expand Down
4 changes: 2 additions & 2 deletions livekit-server/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ spec:
protocol: UDP
targetPort: rtc-udp
{{- end }}
{{- if .Values.livekit.prometheus_port }}
- port: {{ .Values.livekit.prometheus_port }}
{{- if (include "livekit-server.prometheus_port" .) }}
- port: {{ include "livekit-server.prometheus_port" . }}
targetPort: metrics
protocol: TCP
name: metrics
Expand Down
11 changes: 10 additions & 1 deletion livekit-server/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.serviceMonitor.create .Values.livekit.prometheus_port -}}
{{- if and .Values.serviceMonitor.create (include "livekit-server.prometheus_port" .) -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand All @@ -14,6 +14,15 @@ spec:
- port: metrics
path: /
interval: {{ .Values.serviceMonitor.interval }}
{{- if and .Values.livekit.prometheus.username .Values.livekit.prometheus.password }}
basicAuth:
password:
name: {{ include "livekit-server.serviceMonitorSecretName" . }}
key: password
username:
name: {{ include "livekit-server.serviceMonitorSecretName" . }}
key: username
{{- end }}
selector:
matchLabels:
{{- include "livekit-server.selectorLabels" . | nindent 6 }}
Expand Down
11 changes: 11 additions & 0 deletions livekit-server/templates/servicemonitorsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if and .Values.serviceMonitor.create .Values.livekit.prometheus .Values.livekit.prometheus.username .Values.livekit.prometheus.password }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "livekit-server.serviceMonitorSecretName" . }}
labels:
{{- include "livekit-server.labels" . | nindent 4 }}
data:
username: {{ .Values.livekit.prometheus.username | b64enc }}
password: {{ .Values.livekit.prometheus.password | b64enc }}
{{- end }}
4 changes: 4 additions & 0 deletions livekit-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,7 @@ serviceMonitor:
name: ""
# The scrape interval
interval: 30s

# The name of the secret to use.
# If not set and create is true, a name is generated using the fullname template
secretName: ""

0 comments on commit 8d6b2d1

Please sign in to comment.