I'm deploying livekit in Kubernetes. Does it make ...
# ask-ai
b
I'm deploying livekit in Kubernetes. Does it make sense to have more than one replica of the agent pod? Are agent dispatch processes run inside the server pod, or inside the agent pod?
t
Thanks for reaching out, Albert. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When deploying LiveKit on Kubernetes, it’s a great idea to run more than one replica of the agent pod to ensure high availability and reliability. While a single replica might work fine for development or low-traffic situations, for production environments, having multiple agent instances per
agent_name
really helps prevent issues like intermittent connection failures. This way, your system stays robust and smooth! As for how agent dispatch processes work, they’re thoughtfully managed by the LiveKit server. The server balances jobs across the available agent workers using a worker pool model. Each agent worker runs as its own pod, and when a job comes in, the server assigns it to an available worker. Then, each job runs in its own sub-process within the agent pod, which keeps everything nicely isolated and running concurrently without a hitch. Sources: Troubleshooting & Common Issues | livekit/livekit_composite | DeepWiki | Deploying to custom environments | LiveKit Docs
b
Good, and which communications should be granted between the agent and the livekit server pods? Say they are on different machines, which rules should i make sure i put in the security group?
t
To help ensure smooth communication between your LiveKit agent and server pods across different machines, here are some key configurations to keep in mind: • Firewall Rules: Make sure to allow TCP traffic on port
7880
(this is the default for RTC and RoomService communication). You might also want to open port
7881
for WebRTC ICE over TCP fallback. Don’t forget to open the UDP port range specified in your configuration (usually
50000–60000
) to support WebRTC media traffic. • Authentication: Use access tokens that include a
VideoGrant
with the
Agent
permission to enable secure agent-to-server communication. • WebSocket Signaling: It's important to allow WebSocket connections from agent pods to server pods, as this is how they primarily communicate. • Network Segmentation: Consider using Access Control Lists (ACLs) to keep traffic restricted to authorized services only, enhancing your security. • Kubernetes-Specific: If you’re working with Kubernetes, double-check your host networking setup and use the Helm chart for deployment—it helps manage TLS termination and routing smoothly. For the exact port numbers and other settings, please take a look at your
config.yaml
file and Helm chart values, since defaults can vary depending on your production environment. If you’d like, I’m here to help you with any specific configurations or answer any questions you have! Sources: Deploy to Kubernetes | LiveKit Docs | LiveKit | config-sample.yaml