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/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/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 ea17ac2..6842a22 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: @@ -14,9 +18,16 @@ 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 - + {{- 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 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: