On February 19, 2025, Péter Megyesi, CEO of L7mp, joined host Arin Sime to dive into the complexities of running WebRTC media servers in Kubernetes environments. While containerization of WebRTC applications has become common practice, integrating these containers into Kubernetes presents unique challenges due to WebRTC’s distinct networking model.
They explore why traditional WebRTC connectivity methods break in Kubernetes environments and discuss practical solutions using TURN servers. The session covers the evolution of WebRTC deployments from simple containerization to fully Kubernetes-native implementations, including an introduction to STUNner – an open-source project specifically designed to bridge the gap between WebRTC and Kubernetes networking.
They also discuss real-world architectural patterns, common pitfalls, and best practices for running production-grade WebRTC services in Kubernetes clusters.
Bonus Content
- Our regular monthly industry chat with Tsahi Levent-Levi. This month’s topic: Is the AV1 Video Codec Taking Over WebRTC? You can also watch this content on our YouTube channel.
Watch Episode 99!
Key Insights
⚡ Kubernetes is the leading container orchestration tool. Due to its flexibility, scalability, and strong community support, it has become the go-to solution for managing complex applications across multiple environments. Peter sheds light on how Kubernetes came to be, saying, “Then came Kubernetes because Docker was such a cool tool that everyone just started using it, and everyone realized that, okay, it’s very easy to build and run container on one server, but if you grow out that one server, running containers on multiple servers, it’s really, really hard.”
⚡ TURN servers are key for reliable WebRTC performance. While STUN servers can help establish connections in many cases, they fall short when it comes to users behind restrictive firewalls or complex network devices. This is when TURN servers are indispensable. Peter explains, “ Even if you do it, you have to face that issue that, okay, maybe your peer can connect to you using this like STUN and this public IPs, but how can you connect to an enterprise customer who are behind a restrictive firewall? And then, there is no way to do that other than using a TURN server. So, even if you do this again, you will need a TURN server anyway. You will always need a turn server right for this kind of like users behind restrictive firewalls and then just like complicated net devices.”
⚡ The future of Kubernetes with AI and automation. As tech evolves, the complexity of infrastructures grows, especially with the integration of AI, WebRTC, and other essential services. According to Peter, Kubernetes has become a powerful tool to manage these complex architectures. He explains, “ Kubernetes is basically good for when you have this kind of complex architecture. So, if you just have one monolithic service you want to put out on the Internet, that’s not necessarily the case when you want to use Kubernetes. But if you think about this AI agents and WebRTC and a lot of other services that you want to put around it, like authentication, signaling, TURN again, and then databases, all the proxies and stuff. So, it just builds up to a complex architecture. It’s really, really hard to build, I think without Kubernetes.”
Episode Highlights
How Kubernetes revolutionized container orchestration and solved scaling challenges
Docker made it easy to run containers on a single server, but scaling across multiple servers created new challenges. That’s when Kubernetes stepped in, solving the complex issue of container orchestration.
As Peter puts it, “Then came Kubernetes because Docker was such a cool tool that everyone just started using it, and everyone realized that, okay, it’s very easy to build and run container on one server. But if you grow out that one server running containers on multiple servers, it’s really hard. Because then you have a lot of problems of ‘Which server that I want to run my container? How do they communicate with each other? How do external users come to talk to my applications?’ So then, this became this problem of container orchestration, which means how do I organize multiple servers or we just called nodes because they can be either physical or virtual, it doesn’t really matter to one so-called clusters, so group them together as just one giant team and then just run these containers seamlessly.”
STUN and TURN servers in Kubernetes environments
Implementing STUN and TURN protocols in real-time apps is challenging, especially when working with Kubernetes. Peter explains why, “How it works is these peers chose random UDP ports, and via signaling, I realized, okay, here’s my random port, try to connect me here, and that’s just not how the current web or Kubernetes or any other cloud team, is just supposed to work. So Kubernetes itself and all the other, let’s say, major cloud providers were made mostly for, let’s say, HTTP, so web traffic, which is inherently, first of all, stateless, and it’s just a query response. So it’s very fast. I ask one query, I get an answer. I ask another query, maybe goes to another server, but I get the same response. So that’s the idea. And also Kubernetes was built for this, and most of the use cases there were built for this HTTP and web.”
TURN servers are essential for Kubernetes networking
In Kubernetes, real-time apps face unique networking challenges that demand reliable solutions. One such solution is the use of TURN servers, which play a crucial role in enabling seamless communication between users and media servers.
As Peter nicely puts it, “We like to say that if you’re in Kubernetes and you want to use the normal networking so that you can use all the features that Kubernetes provides you, there is no other option than to use a TURN server. So, TURN is different than STUN. TURN is basically a relay. So, you as a user can connect to a TURN server, and then the media server can connect to the same TURN server, let’s say, and then it can just hook your traffic together. So that’s kind of cool. That’s a basic idea. You can use different type of TURN, but that’s the most popular because that’s the easiest to implement.”
Up Next! WebRTC Live Episode 100
Building AI Virtual Assistants into Meeting Platforms with AVA Intellect
Wednesday, March 19, 2025 at 12:30 pm Eastern.