From d28f71ddf4b55c1edb443a7ba86272bb95e787a1 Mon Sep 17 00:00:00 2001 From: "Alisson R. de Oliveira" <13340485+alisson276@users.noreply.github.com> Date: Thu, 6 Feb 2025 08:29:07 +0000 Subject: [PATCH 1/4] feat: Add annotations to ingress --- ingress/Chart.yaml | 2 +- ingress/templates/service.yaml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ingress/Chart.yaml b/ingress/Chart.yaml index 75fefb0..a653da3 100644 --- a/ingress/Chart.yaml +++ b/ingress/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: ingress description: Ingress is used by LiveKit to ingest streams produced by external workflows type: application -version: 1.4.3 +version: 1.4.4 appVersion: "v1.4.3" sources: diff --git a/ingress/templates/service.yaml b/ingress/templates/service.yaml index ea17ac2..275a201 100644 --- a/ingress/templates/service.yaml +++ b/ingress/templates/service.yaml @@ -3,6 +3,10 @@ kind: Service metadata: name: {{ include "ingress.fullname" . }} labels: {{- include "ingress.labels" . | nindent 4 }} + {{- with .Values.loadBalancer.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: type: {{ default "LoadBalancer" .Values.ingress.serviceType }} ports: From 35ab5b86224f46842b422d4a54089bf6c5399b83 Mon Sep 17 00:00:00 2001 From: "Alisson R. de Oliveira" <13340485+alisson276@users.noreply.github.com> Date: Thu, 6 Feb 2025 08:43:21 +0000 Subject: [PATCH 2/4] fix: prometheus_port is deprecated --- livekit-server/templates/_helpers.tpl | 11 +++++++++++ livekit-server/templates/deployment.yaml | 4 ++-- livekit-server/templates/service.yaml | 4 ++-- livekit-server/templates/servicemonitor.yaml | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/livekit-server/templates/_helpers.tpl b/livekit-server/templates/_helpers.tpl index e136477..bacc329 100644 --- a/livekit-server/templates/_helpers.tpl +++ b/livekit-server/templates/_helpers.tpl @@ -71,3 +71,14 @@ Create the name of the service monitor to use {{- default "default" .Values.serviceMonitor.name }} {{- end }} {{- end }} + +{{/* +Prometheus port +*/}} +{{- define "livekit-server.prometheus_port" -}} +{{- if .Values.livekit.prometheus }} +{{- .Values.livekit.prometheus.port }} +{{- else }} +{{- default "" .Values.livekit.prometheus_port }} +{{- end }} +{{- end }} diff --git a/livekit-server/templates/deployment.yaml b/livekit-server/templates/deployment.yaml index 7b35cee..58e1bde 100644 --- a/livekit-server/templates/deployment.yaml +++ b/livekit-server/templates/deployment.yaml @@ -76,9 +76,9 @@ 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 }} + containerPort: {{ include "livekit-server.prometheus_port" . }} hostPort: {{ .Values.livekit.prometheus_port }} protocol: TCP {{- end }} diff --git a/livekit-server/templates/service.yaml b/livekit-server/templates/service.yaml index 6601943..694fa1c 100644 --- a/livekit-server/templates/service.yaml +++ b/livekit-server/templates/service.yaml @@ -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 diff --git a/livekit-server/templates/servicemonitor.yaml b/livekit-server/templates/servicemonitor.yaml index 73b62a9..12b9459 100644 --- a/livekit-server/templates/servicemonitor.yaml +++ b/livekit-server/templates/servicemonitor.yaml @@ -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: From 4e98d76c4183c8e23b2e78fca6bdde8d0f4e1182 Mon Sep 17 00:00:00 2001 From: "Alisson R. de Oliveira" <13340485+alisson276@users.noreply.github.com> Date: Thu, 6 Feb 2025 08:44:38 +0000 Subject: [PATCH 3/4] feat: Make whip optional --- ingress/templates/deployment.yaml | 4 ++-- ingress/templates/service.yaml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ingress/templates/deployment.yaml b/ingress/templates/deployment.yaml index c2d2307..e09555f 100644 --- a/ingress/templates/deployment.yaml +++ b/ingress/templates/deployment.yaml @@ -52,12 +52,12 @@ spec: containerPort: {{ .Values.ingress.http_relay_port }} protocol: TCP {{- end }} - {{- if .Values.ingress.rtmp_port }} + {{- if and .Values.ingress.rtmp_port (gt (int .Values.ingress.rtmp_port) 0) }} - name: rtmp-port containerPort: {{ .Values.ingress.rtmp_port }} protocol: TCP {{- end }} - {{- if .Values.ingress.whip_port }} + {{- if and .Values.ingress.whip_port (gt (int .Values.ingress.whip_port) 0) }} - name: whip-port containerPort: {{ .Values.ingress.whip_port }} protocol: TCP diff --git a/ingress/templates/service.yaml b/ingress/templates/service.yaml index 275a201..f3818b3 100644 --- a/ingress/templates/service.yaml +++ b/ingress/templates/service.yaml @@ -18,6 +18,7 @@ spec: - port: {{ .Values.ingress.rtmp_port }} protocol: TCP name: rtmp + {{- if and .Values.ingress.whip_port (gt (int .Values.ingress.whip_port) 0) }} - port: {{ .Values.ingress.whip_port }} protocol: TCP name: whip From 7d832627c3651bea1748d5f4bc419e74f39019d7 Mon Sep 17 00:00:00 2001 From: "Alisson R. de Oliveira" <13340485+alisson276@users.noreply.github.com> Date: Thu, 6 Feb 2025 08:52:37 +0000 Subject: [PATCH 4/4] feat: Add Prometheus monitoring for ingress and egress --- egress/templates/_helpers.tpl | 11 +++++++++++ egress/templates/podmonitor.yaml | 20 ++++++++++++++++++++ egress/values.yaml | 11 +++++++++++ ingress/Chart.yaml | 2 +- ingress/templates/_helpers.tpl | 11 +++++++++++ ingress/templates/service.yaml | 8 +++++++- ingress/templates/servicemonitor.yaml | 20 ++++++++++++++++++++ ingress/values.yaml | 11 +++++++++++ 8 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 egress/templates/podmonitor.yaml create mode 100644 ingress/templates/servicemonitor.yaml diff --git a/egress/templates/_helpers.tpl b/egress/templates/_helpers.tpl index e1dbcfe..ffa0dbb 100644 --- a/egress/templates/_helpers.tpl +++ b/egress/templates/_helpers.tpl @@ -60,3 +60,14 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Create the name of the pod monitor to use +*/}} +{{- define "egress.podMonitorName" -}} +{{- if .Values.podMonitor.create }} +{{- default (include "egress.fullname" .) .Values.podMonitor.name }} +{{- else }} +{{- default "default" .Values.podMonitor.name }} +{{- end }} +{{- end }} diff --git a/egress/templates/podmonitor.yaml b/egress/templates/podmonitor.yaml new file mode 100644 index 0000000..0b04fea --- /dev/null +++ b/egress/templates/podmonitor.yaml @@ -0,0 +1,20 @@ +{{- if and .Values.podMonitor.create .Values.egress.prometheus_port -}} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "egress.podMonitorName" . }} + labels: + {{- include "egress.labels" . | nindent 4 }} + {{- with .Values.podMonitor.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + path: / + interval: {{ .Values.podMonitor.interval }} + selector: + matchLabels: + {{- include "egress.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/egress/values.yaml b/egress/values.yaml index 1343c35..fe71693 100644 --- a/egress/values.yaml +++ b/egress/values.yaml @@ -41,3 +41,14 @@ securityContext: {} tolerations: [] affinity: {} + +podMonitor: + # Specifies whether a service monitor should be created + create: false + # Annotations to add to the service monitor + annotations: {} + # The name of the service monitor to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + # The scrape interval + interval: 30s diff --git a/ingress/Chart.yaml b/ingress/Chart.yaml index a653da3..75fefb0 100644 --- a/ingress/Chart.yaml +++ b/ingress/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: ingress description: Ingress is used by LiveKit to ingest streams produced by external workflows type: application -version: 1.4.4 +version: 1.4.3 appVersion: "v1.4.3" sources: diff --git a/ingress/templates/_helpers.tpl b/ingress/templates/_helpers.tpl index 8c9e045..045918e 100644 --- a/ingress/templates/_helpers.tpl +++ b/ingress/templates/_helpers.tpl @@ -60,3 +60,14 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Create the name of the service monitor to use +*/}} +{{- define "ingress.serviceMonitorName" -}} +{{- if .Values.serviceMonitor.create }} +{{- default (include "ingress.fullname" .) .Values.serviceMonitor.name }} +{{- else }} +{{- default "default" .Values.serviceMonitor.name }} +{{- end }} +{{- end }} diff --git a/ingress/templates/service.yaml b/ingress/templates/service.yaml index f3818b3..6842a22 100644 --- a/ingress/templates/service.yaml +++ b/ingress/templates/service.yaml @@ -22,6 +22,12 @@ spec: - port: {{ .Values.ingress.whip_port }} protocol: TCP name: whip - + {{- end }} + {{- if .Values.ingress.prometheus_port }} + - port: {{ .Values.ingress.prometheus_port }} + targetPort: metrics + protocol: TCP + name: metrics + {{- end }} selector: {{- include "ingress.selectorLabels" . | nindent 4 }} diff --git a/ingress/templates/servicemonitor.yaml b/ingress/templates/servicemonitor.yaml new file mode 100644 index 0000000..caa6fb9 --- /dev/null +++ b/ingress/templates/servicemonitor.yaml @@ -0,0 +1,20 @@ +{{- if and .Values.serviceMonitor.create .Values.ingress.prometheus_port -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "ingress.serviceMonitorName" . }} + labels: + {{- include "ingress.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + path: / + interval: {{ .Values.serviceMonitor.interval }} + selector: + matchLabels: + {{- include "ingress.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/ingress/values.yaml b/ingress/values.yaml index 00d8b06..bd9b562 100644 --- a/ingress/values.yaml +++ b/ingress/values.yaml @@ -60,3 +60,14 @@ securityContext: {} tolerations: [] affinity: {} + +serviceMonitor: + # Specifies whether a service monitor should be created + create: false + # Annotations to add to the service monitor + annotations: {} + # The name of the service monitor to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + # The scrape interval + interval: 30s