Skip to content

Commit

Permalink
Merge pull request #10 from firefliesai/feature-sc-53478-hosting-live…
Browse files Browse the repository at this point in the history
…kit-server-on-public-helm-chart

move livekit server to public helm chart
  • Loading branch information
kumari-shubham authored Apr 3, 2024
2 parents e31a3b9 + af0b4b4 commit eb0afea
Show file tree
Hide file tree
Showing 16 changed files with 721 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/livekit-server/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/livekit-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
appVersion: v1.5.3
description: Real-time infrastructure for developers. LiveKit is the open source stack
for streaming audio, video, and data.
name: livekit-server
sources:
- https://github.com/livekit/livekit
type: application
version: 1.5.3
50 changes: 50 additions & 0 deletions charts/livekit-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-------------------------------------------------------------------------------

LiveKit {{ .Values.image.tag | default .Chart.AppVersion }} has been deployed!

Please ensure that the following ports on the nodes are open on your firewall.

{{- if .Values.livekit.rtc.udp_port }}
* WebRTC UDP {{ .Values.livekit.rtc.udp_port }}
{{- else }}
* WebRTC UDP {{ .Values.livekit.rtc.port_range_start}} - {{ .Values.livekit.rtc.port_range_end}}
{{- end }}
* WebRTC TCP {{ .Values.livekit.rtc.tcp_port }}
{{- if .Values.livekit.turn.enabled }}
{{- if .Values.livekit.turn.udp_port }}
* TURN/UDP {{ .Values.livekit.turn.udp_port }}
{{- end }}
{{- if .Values.livekit.turn.tls_port }}
* TURN/TLS {{ .Values.livekit.turn.tls_port }}
{{- end }}
{{- end }}

{{- if ne .Values.loadBalancer.type "disable" }}

Primary load balancer has been set up for the primary API endpoint. The
following hosts should now be pointed at the load balancer.
{{- range .Values.loadBalancer.tls }}
{{- range .hosts }}
- {{ . }}
{{- end }}
{{- end }}

To determine the load balancer address, run:
{{- if eq .Values.loadBalancer.type "aws" }}
$ kubectl get --namespace {{ .Release.Namespace }} service {{ include "livekit-server.fullname" . }}
{{- else }}
$ kubectl get --namespace {{ .Release.Namespace }} ingress {{ include "livekit-server.fullname" . }}
{{- end }}
{{- else }}
Load balancer has been disabled
{{- end }}

{{- if and .Values.livekit.turn.enabled .Values.livekit.turn.tls_port (not .Values.livekit.turn.external_tls) }}

TURN/TLS has been deployed behind a load balancer, to determine its address, run:
$ kubectl get --namespace {{ .Release.Namespace }} service {{ include "livekit-server.fullname" . }}-turn
You may now map the TURN/TLS domain {{ .Values.livekit.turn.domain }} to this address

{{- end }}

-------------------------------------------------------------------------------
73 changes: 73 additions & 0 deletions charts/livekit-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "livekit-server.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "livekit-server.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "livekit-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "livekit-server.labels" -}}
helm.sh/chart: {{ include "livekit-server.chart" . }}
{{ include "livekit-server.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "livekit-server.selectorLabels" -}}
app.kubernetes.io/name: {{ include "livekit-server.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "livekit-server.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "livekit-server.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the service monitor to use
*/}}
{{- define "livekit-server.serviceMonitorName" -}}
{{- if .Values.serviceMonitor.create }}
{{- default (include "livekit-server.fullname" .) .Values.serviceMonitor.name }}
{{- else }}
{{- default "default" .Values.serviceMonitor.name }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/livekit-server/templates/backendconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if or (eq .Values.loadBalancer.type "gke") (eq .Values.loadBalancer.type "gke-managed-cert") (eq .Values.loadBalancer.type "gke-vpc-native") (eq .Values.loadBalancer.type "gclb") -}}
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: {{ include "livekit-server.fullname" . }}
spec:
{{ .Values.gcp.backendConfig | toPrettyJson }}
{{ end }}
7 changes: 7 additions & 0 deletions charts/livekit-server/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "livekit-server.fullname" . }}
data:
config.yaml: |
{{ toYaml .Values.livekit | indent 4 }}
147 changes: 147 additions & 0 deletions charts/livekit-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "livekit-server.fullname" . }}
labels:
{{- include "livekit-server.labels" . | nindent 4 }}
{{- if .Values.deploymentAnnotations }}
annotations:
{{- toYaml .Values.deploymentAnnotations | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "livekit-server.selectorLabels" . | nindent 6 }}
{{- if .Values.deploymentStrategy }}
strategy:
{{- toYaml .Values.deploymentStrategy | nindent 4 }}
{{- end }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
{{- include "livekit-server.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "livekit-server.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.podHostNetwork }}
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["--disable-strict-config"]
env:
- name: LIVEKIT_CONFIG
valueFrom:
configMapKeyRef:
name: {{ include "livekit-server.fullname" . }}
key: config.yaml
{{- if and .Values.livekit.turn.enabled .Values.livekit.turn.tls_port (not .Values.livekit.turn.external_tls) }}
- name: LIVEKIT_TURN_CERT
value: /etc/lkcert/tls.crt
- name: LIVEKIT_TURN_KEY
value: /etc/lkcert/tls.key
{{- end }}
ports:
- name: http
containerPort: {{ .Values.livekit.port }}
protocol: TCP
{{- if .Values.livekit.rtc.udp_port }}
- name: rtc-udp
containerPort: {{ .Values.livekit.rtc.udp_port }}
hostPort: {{ .Values.livekit.rtc.udp_port }}
protocol: UDP
{{- end }}
{{- if .Values.livekit.rtc.tcp_port }}
- name: rtc-tcp
containerPort: {{ .Values.livekit.rtc.tcp_port }}
hostPort: {{ .Values.livekit.rtc.tcp_port }}
protocol: TCP
{{- end }}
{{- if .Values.livekit.prometheus_port }}
- name: metrics
containerPort: {{ .Values.livekit.prometheus_port }}
hostPort: {{ .Values.livekit.prometheus_port }}
protocol: TCP
{{- end }}
{{- if .Values.livekit.turn.enabled }}
{{- if .Values.livekit.turn.tls_port }}
- name: turn-tls
containerPort: {{ .Values.livekit.turn.tls_port }}
hostPort: {{ .Values.livekit.turn.tls_port }}
protocol: TCP
{{- end }}
{{- if .Values.livekit.turn.udp_port }}
- name: turn-udp
containerPort: {{ .Values.livekit.turn.udp_port }}
hostPort: {{ .Values.livekit.turn.udp_port }}
protocol: UDP
{{- end }}
{{- end }}
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.storeKeysInSecret.enabled (and .Values.livekit.turn.enabled .Values.livekit.turn.tls_port (not .Values.livekit.turn.external_tls)) }}
volumeMounts:
{{- if .Values.storeKeysInSecret.enabled }}
- name: keys-volume
mountPath: {{ .Values.livekit.key_file }}
subPath: {{ .Values.livekit.key_file }}
{{- end }}
{{- if and .Values.livekit.turn.enabled .Values.livekit.turn.tls_port (not .Values.livekit.turn.external_tls) }}
- name: lkturncert
mountPath: /etc/lkcert
readOnly: true
{{- end }}
{{- end }}
{{- if or .Values.storeKeysInSecret.enabled (and .Values.livekit.turn.enabled .Values.livekit.turn.tls_port (not .Values.livekit.turn.external_tls)) }}
volumes:
{{- if .Values.storeKeysInSecret.enabled }}
- name: keys-volume
secret:
secretName: {{ (tpl .Values.storeKeysInSecret.existingSecret .) | default (include "livekit-server.fullname" .) }}
defaultMode: 0600
{{- end }}
{{- if and .Values.livekit.turn.enabled .Values.livekit.turn.tls_port (not .Values.livekit.turn.external_tls) }}
- name: lkturncert
secret:
secretName: {{ required "tls secret required if turn enabled" .Values.livekit.turn.secretName }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
44 changes: 44 additions & 0 deletions charts/livekit-server/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- if .Values.autoscaling.enabled }}
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: autoscaling/v2
{{- else }}
apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "livekit-server.fullname" . }}
labels:
{{- include "livekit-server.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "livekit-server.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- else }}
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- else }}
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit eb0afea

Please sign in to comment.