Thanks — I’ll provide a clear, step‑by‑step deployment guide for running LiveKit on a Google Cloud VM and attaching a load balancer. First I’ll outline two recommended options (so you can pick which fits your needs), then give the detailed steps for the common choice (Network TCP/UDP Load Balancer for full WebRTC). Before I give exact Cloud Console clicks and example firewall rules, I have two quick questions so the steps match your setup:
1. Which load balancer do you want?
◦ A: Network (TCP/UDP) Load Balancer — recommended for full WebRTC (signaling + UDP media).
◦ B: External HTTP(S) Load Balancer — only for signaling (wss/HTTP); media must be handled separately.
1. Which ports is your LiveKit server actually using on the VM? (you previously noted 7881 is accessible) — please confirm:
◦ Signaling (TCP) port: _ (e.g., 7881 or 7880 or 443)
◦ Media (UDP) port: _ (e.g., 7882 or custom)
Also tell me if you’re using a single VM or a Managed Instance Group (MIG).
If you want the Network (TCP/UDP) Load Balancer (recommended), here are the step-by-step instructions to follow. Replace ports below with the ports you confirm in your reply.
Summary of what we’ll do
• Ensure VM and LiveKit are listening on the chosen ports.
• Reserve a static external IP.
• Create a Network (TCP/UDP) Load Balancer with frontend bindings for TCP (signaling) and UDP (media).
• Attach your VM (or instance group) as the backend and create a health check.
• Create firewall rules allowing the load balancer and clients to reach the VM ports.
• Test connectivity from a client.
Detailed steps (Network TCP/UDP Load Balancer)
1. Prepare the VM and LiveKit
◦ Confirm LiveKit is running and listening on the chosen ports. Example defaults: signaling TCP 7880 (or 7881 if that’s what you use) and media UDP 7882.
◦ If using TLS on port 443, ensure LiveKit is configured with certificates and listens on 443.
1. Reserve a static external IP
◦ Console: VPC network → External IP addresses → Reserve static address. Note the reserved IP (this will be the LB frontend IP).
1. Create a health check
◦ Console: Network services → Load balancing → Health checks → Create health check.
◦ Type: TCP
◦ Port: set to the signaling TCP port your server listens on (e.g., 7881).
◦ Configure check interval, timeout, and healthy/unhealthy thresholds (defaults are fine).
1. Create the Network (TCP/UDP) Load Balancer
◦ Console: Network services → Load balancing → Create load balancer → Choose "From Internet to my VMs" → Choose "TCP/UDP Network Load Balancer".
◦ Frontend configuration:
▪︎ IP: select the reserved static external IP.
▪︎ Protocols/ports: add TCP for signaling (e.g., 7881) and UDP for media (e.g., 7882). If you need additional ports add them here.
◦ Backend configuration:
▪︎ Backend type: Instance group (select your instance group or single instance backend).
▪︎ Backend port: map to the VM listening ports (e.g., TCP 7881, UDP 7882).
▪︎ Attach the health check you created.
◦ Session affinity: usually NONE for WebRTC.
◦ Create the LB.
1. Firewall rules
◦ Create firewall rules to allow ingress to your VM network on the ports you exposed:
▪︎ Rule 1 (TCP signaling): Allow ingress tcp:<signaling-port> from 0.0.0.0/0 (or restrict to client IP ranges as needed). Target by network tag or service account used by VM.
▪︎ Rule 2 (UDP media): Allow ingress udp:<media-port> from 0.0.0.0/0 (or restrict).
▪︎ Rule 3 (Health checks): Allow GCP health check IP ranges to reach the signaling port — or allow tcp:<signaling-port> from 35.191.0.0/16 and 209.85.152.0/22 (or use the documented GCP health check ranges).
◦ Apply network tags to the VM and scope rules to those tags.
1. TLS considerations
◦ If you want TLS on signaling:
▪︎ Terminate TLS on the VM (LiveKit handles TLS): use TCP 443 on frontend/backends and keep UDP media on separate UDP ports.
▪︎ If you terminate TLS at an HTTP(S) LB, note HTTP(S) LB does NOT support UDP; media must be reachable separately.
1. Testing
◦ Connect a client to the LB IP or DNS (wss//<IP or host><signaling-port>) and join a room. Verify audio/video flows.
◦ Check health checks on the Load Balancer page to ensure the instance is healthy.
◦ If media does not flow, check that UDP port is open and reachable (use tools like udping or WebRTC diagnostics).
Optional: Using Managed Instance Group (MIG)
• If you plan to scale, place LiveKit VMs in a MIG so you can autoscale. Ensure the startup script configures LiveKit with the correct instance-specific configuration (room/cluster settings) and that persistent storage or state is handled appropriately.
If you want, I can provide:
• Exact Cloud Console click-by-click steps (with the specific port numbers you confirm).
• Example gcloud commands and sample firewall-rule commands for automation.
• Example health check settings and troubleshooting commands (e.g., how to check port listen state on the VM).
Tell me:
• Which LB option (A or B) you prefer, and
• The exact signaling TCP port and media UDP port your LiveKit server uses, and
• Single VM or MIG.
I’ll then give the precise Cloud Console steps or gcloud commands tailored to your setup.