what are the steps needed to self-host livekit rec...
# ask-ai
a
what are the steps needed to self-host livekit recording agents? what is it needed to self-host the whole stack?
t
Thanks for reaching out, Mohammed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’ll walk you through what’s required to self‑host LiveKit recording agents and what’s needed to self‑host the entire LiveKit stack. Before I dive into detailed steps: which deployment option are you planning to use for the stack and agents — Docker on a VM, Kubernetes, or a PaaS (Render/Fly/other)? That will let me tailor the instructions and examples. Below is a concise, deploy-agnostic checklist and step-by-step plan you can follow. What you need to host recording agents • Agent code: Use the LiveKit Agents SDK (Node or Python) to implement your agent logic (recording, transcription, moderation, etc.). • Container image: Create a Dockerfile for the agent (starter templates exist for Python and Node). • Credentials & env vars: ◦
LIVEKIT_URL
◦
LIVEKIT_API_KEY
◦
LIVEKIT_API_SECRET
◦ Optional: AI provider keys (e.g., Deepgram, OpenAI) for transcription/AI features. • Secrets management: Store/update secrets in your deployment platform (you can update agent secrets without redeploying via CLI tooling). • Outbound connectivity: Agents connect outbound to your LiveKit server (no inbound ports required on agent hosts). • Scaling: Run multiple agent replicas for capacity and HA; use a load balancer or Kubernetes to manage scale. • Dispatch configuration: Ensure your LiveKit server is configured to dispatch jobs to agents (matching agent names and scoped tokens). High-level steps to deploy recording agents 1. Build agent: ◦ Implement agent using LiveKit Agents SDK (Node or Python). 1. Containerize: ◦ Add a Dockerfile and build an image. 1. Configure environment: ◦ Inject LiveKit server URL, API key/secret, and any AI keys. 1. Deploy: ◦ Run containers on your chosen platform (Kubernetes recommended for production; VMs or PaaS also supported). 1. Register and validate: ◦ Confirm the agent connects to LiveKit and receives job dispatches. 1. Monitor & scale: ◦ Add logging/metrics, and scale replicas as needed. What you need to self-host the full LiveKit stack • LiveKit server (SFU/media server) ◦ Deployable via Docker, Kubernetes (Helm chart available), or cloud-init on a VM. ◦ Requires API key & secret to issue tokens and for agent/job dispatch. • Networking & domain ◦ A domain name for the server (e.g., livekit.example.com). ◦ SSL certificate (Let’s Encrypt or other). ◦ Open required ports: ▪︎ TCP: 7880 (WebSocket), 7881 (HTTP/REST), 443 (if you proxy), SSH 22 ▪︎ UDP: 7882 (WebRTC media) — ensure UDP allowed for WebRTC • Egress/Recording service ◦ Egress runs as a separate service and uses Redis Pub/Sub to coordinate jobs. ◦ Needs GStreamer (and optionally Chrome) for compositing/transcoding. ◦ For hardware-accelerated encoding, install NVIDIA drivers/CUDA and configure GPU. • Supporting components ◦ Redis (for pub/sub used by egress/agents) ◦ Storage for recordings (S3-compatible object store or local storage depending on your egress configuration) ◦ Optional DB or observability stack for metrics and logs • High availability & region planning ◦ Deploy multiple LiveKit server instances or use k8s for HA. ◦ Co-locate agents and AI services with the LiveKit server to minimize latency for recording/real-time processing. High-level steps to deploy the full stack 1. Provision infrastructure: ◦ Choose cloud provider or on-prem VMs/Kubernetes cluster. 1. Deploy LiveKit server: ◦ Docker run, use the Helm chart, or use cloud-init templates for VM provisioning. 1. Configure DNS and TLS: ◦ Point your domain to the server and install SSL certs. 1. Deploy Redis and egress: ◦ Start Redis; deploy the egress service (configure pub/sub and storage). 1. Deploy agents: ◦ Containerize and deploy agents; ensure they can reach the LiveKit server. 1. Test recordings: ◦ Create a test room, have an agent join and trigger a recording/egress job, verify output storage and transcoding. 1. Monitor and optimize: ◦ Add observability, scale workers, and optionally add GPUs for encoding. Important operational notes • Agents make outbound connections — you don’t need to open inbound ports on agent hosts. • Egress/recording depends on Redis and can require GStreamer/Chrome. If you need GPU-accelerated encoding, install NVIDIA drivers and CUDA on the egress hosts. • Match agent names and token permissions so LiveKit can dispatch jobs to your agents (scoped tokens with roomJoin, publish/subscribe as needed). • For low latency, run agents and LiveKit server in the same region as clients and any AI services. If you want, I can: • Provide a sample Dockerfile and minimal agent example (Node or Python). • Give exact docker run or Helm chart install commands for your chosen deployment option. • Walk through how to configure egress with Redis and S3 storage. Which deployment option should I prepare the detailed steps for? Sources: Collect recording consent with tasks | LiveKit Documentation | Self-hosted deployments | LiveKit Documentation | examples/drive-thru | livekit/livekit_composite | DeepWiki | Introduction | LiveKit Documentation | server-sdk-js | livekit/livekit_composite | DeepWiki
a
we are using kubernetes
t
Thanks — since you’re on Kubernetes, here’s a Kubernetes‑focused plan with concrete, ordered steps and examples to self‑host LiveKit recording agents and the full LiveKit stack. I’ll include what to deploy, important config, and operational tips. If you want, I can provide Helm values and sample manifests next. Before we start: do you already have a Kubernetes cluster (provider, node sizes, GPU nodes)? Also tell me which storage you’ll use for recordings (S3-compatible or persistent volumes). That will let me give exact YAML/Helm snippets. 1) Components to run on Kubernetes • livekit-server (the SFU/media server) • livekit-egress (recording/egress service) • Redis (Pub/Sub for egress coordination) • recording agents (your agent containers built from LiveKit Agents SDK) • Optional: object storage (S3 or S3-compatible), ingress controller, cert-manager, monitoring (Prometheus/Grafana), and a load balancer 2) High-level architecture & responsibilities • livekit-server: handles rooms, signaling, and SFU media • livekit-egress: receives egress jobs via Redis, runs GStreamer/Chrome for transcoding/compositing • Redis: pub/sub message bus between livekit-server and egress/agents • Agents: connect outbound to livekit-server to join rooms and perform recording/transcription/AI tasks • Storage: recordings uploaded to S3 or stored in a PVC depending on configuration 3) Cluster & node requirements • Standard nodes for server, Redis, agents • For egress/transcoding, use nodes with GPUs if you want hardware encoding (install NVIDIA drivers + device plugin) • Open UDP and TCP at your cloud/firewall level for the LiveKit service (K8s service/ingress handles external exposure) • Recommended: Autoscaling for agent/egress replicas; node pools for GPU vs CPU workloads 4) Networking, domain & TLS • Create a DNS record for your LiveKit hostname (e.g., livekit.example.com). • Use an ingress controller (NGINX/Traefik) or a LoadBalancer service exposing ports. • Terminate TLS via cert-manager and Let’s Encrypt, or provide your TLS certs to the ingress. • Ensure UDP traffic is forwarded for WebRTC (LoadBalancer or NodePort with external UDP support). 5) Deploying livekit-server on Kubernetes (short path) • Use the official LiveKit Helm chart (livekit-helm). • Key Helm values to set: ◦
app.livekitKeys
or env vars: API key:secret ◦ `ingress.hosts[0].host`: your domain ◦ Configure service type (LoadBalancer) and UDP port mapping for WebRTC (typically 7882) • Post-deploy: verify pods are Running and service endpoints are reachable; test a client connecting to the domain. 6) Deploying Redis • Deploy a managed Redis or a Kubernetes Redis (Helm chart like bitnami/redis). • Ensure Redis is reachable by
livekit-egress
and by any component that needs pub/sub. 7) Deploying livekit-egress (recording) • Deploy egress as its own Deployment/StatefulSet. • Environment/config: ◦ Redis connection string ◦ Object storage credentials (S3_BUCKET, S3_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) if using S3 ◦ Any GStreamer/Chrome flags and temp storage path (PVC) • If using GPU acceleration: ◦ Use node selector/taints for GPU nodes ◦ Add NVIDIA device plugin DaemonSet and set resources.requests/limits for GPUs • Make egress autoscalable if you expect concurrent egress jobs 8) Build & deploy recording agents • Build agents using the LiveKit Agents SDK (Node or Python) and create a Docker image. • Provide env vars/secrets to agent pods: ◦
LIVEKIT_URL
,
LIVEKIT_API_KEY
,
LIVEKIT_API_SECRET
◦ Any AI provider keys (Deepgram, OpenAI, etc.) • Deploy agents as a Deployment with HorizontalPodAutoscaler (HPA) for scale. • Agents do not require inbound ports; they must be able to reach the LiveKit server URL. 9) Secrets & configuration • Use Kubernetes Secrets for API keys and AI credentials. • Use ConfigMaps for non-sensitive configuration (agent names, dispatch settings). • If you want to rotate secrets without redeploying containers, implement a secret-sync or use tools like External Secrets. 10) Job dispatch & token scopes • Ensure livekit-server is configured so it can dispatch jobs to agents/egress: ◦ Agent dispatch is matched by
agent_name
and permissions in your token. ◦ Tokens must include proper grants (roomJoin, canPublish, canSubscribe) for agents. • Validate by issuing a job from server and watching agent logs for job receipt. 11) Storage for recordings • Recommended: S3-compatible storage (AWS S3, MinIO). • Configure egress with proper S3 credentials and bucket; ensure network access from egress pods to S3. • Alternative: Use PVCs for temporary storage then move files to object storage. 12) Observability & monitoring • Expose metrics via Prometheus (livekit exposes Prometheus metrics). • Collect logs (ELK/Fluentd) from server, egress, and agents. • Set alerts for pod restarts, high CPU/GPU usage, Redis latency, and egress failures. 13) Example next steps I can provide • Helm values.yaml for livekit-server tailored to your cluster and domain. • Deployment manifest examples for livekit-egress with Redis and S3 env config. • Sample Deployment + HPA for an agent, plus a Dockerfile starter for Node/Python agents. • GPU node YAML and instructions to enable NVIDIA drivers and device plugin. If you tell me: • Your Kubernetes provider (EKS/GKE/AKS/self-hosted), • Whether you’ll use S3 or PVC for recordings, • If you plan to use GPU nodes for egress, I’ll provide the specific Helm values and sample manifests for those choices. Which details do you want first?