# services/comms/livekit.yaml apiVersion: apps/v1 kind: Deployment metadata: name: livekit labels: app: livekit spec: replicas: 1 selector: matchLabels: app: livekit template: metadata: annotations: checksum/config: livekit-config-v5 labels: app: livekit spec: enableServiceLinks: false nodeSelector: hardware: rpi5 affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 50 preference: matchExpressions: - key: hardware operator: In values: ["rpi5","rpi4"] initContainers: - name: render-config image: alpine:3.20 command: ["/bin/sh","-c"] args: - | set -euo pipefail umask 077 TURN_PASSWORD_ESCAPED="$(printf '%s' "${TURN_PASSWORD}" | sed 's/[\\/&]/\\&/g')" sed "s/@@TURN_PASSWORD@@/${TURN_PASSWORD_ESCAPED}/g" /etc/livekit-template/livekit.yaml > /etc/livekit/livekit.yaml chmod 0644 /etc/livekit/livekit.yaml env: - name: TURN_PASSWORD valueFrom: secretKeyRef: name: turn-shared-secret key: TURN_STATIC_AUTH_SECRET volumeMounts: - name: config-template mountPath: /etc/livekit-template readOnly: true - name: config mountPath: /etc/livekit readOnly: false containers: - name: livekit image: livekit/livekit-server:v1.9.0 command: - /bin/sh - -c - | set -euo pipefail umask 077 printf "%s: %s\n" "${LIVEKIT_API_KEY_ID}" "${LIVEKIT_API_SECRET}" > /var/run/livekit/keys chmod 600 /var/run/livekit/keys exec /livekit-server --config /etc/livekit/livekit.yaml --key-file /var/run/livekit/keys env: - name: LIVEKIT_API_KEY_ID value: primary - name: LIVEKIT_API_SECRET valueFrom: secretKeyRef: name: livekit-api key: primary ports: - containerPort: 7880 name: http protocol: TCP - containerPort: 7881 name: rtc-tcp protocol: TCP - containerPort: 7882 name: rtc-udp protocol: UDP - containerPort: 7883 name: rtc-udp2 protocol: UDP volumeMounts: - name: config mountPath: /etc/livekit readOnly: true - name: runtime-keys mountPath: /var/run/livekit resources: requests: cpu: 500m memory: 512Mi limits: cpu: "2" memory: 1Gi volumes: - name: config-template configMap: name: livekit-config items: - key: livekit.yaml path: livekit.yaml - name: config emptyDir: {} - name: runtime-keys emptyDir: {} --- apiVersion: v1 kind: Service metadata: name: livekit annotations: metallb.universe.tf/address-pool: communication-pool spec: type: LoadBalancer loadBalancerClass: metallb loadBalancerIP: 192.168.22.6 externalTrafficPolicy: Local selector: app: livekit ports: - name: http port: 7880 targetPort: 7880 protocol: TCP - name: rtc-tcp port: 7881 targetPort: 7881 protocol: TCP - name: rtc-udp-7882 port: 7882 targetPort: 7882 protocol: UDP - name: rtc-udp-7883 port: 7883 targetPort: 7883 protocol: UDP