Server in Kubernetes with TURN


I would like to deploy SFU server to Kubernetes cluster.
The problem is that I would like to make it possible to have multiple instances working in parallel on the same cluster, so using host network is not an option.
I am not an expert on WebRTC, but I am thinking of deploying TURN server in the same namespace as SFU and expose it outside the cluster through dedicated IP and use it to connect to every SFU instance.
I assume that it would require exposing only 3016 port on SFU.
However I have no idea how to enforce using TURN on client side (it is Vue app) and I have no idea if my proposal has a minimal chance to be working, can someone more experienced express his thoughts?
In before - I know that without using host network the performance of connection will be poorer, but this deployment is only for development purposes, so I don’t mind.

It’d only work if your code is considerably stateless. Perhaps confused about TURN but you touch that last when the setup is groovy if necessary.

So perhaps look into setting something up that’d allow these servers to be discovered, used and as well keep track of their usage so when more viewers/publishers make requests they can be routed properly to their respective servers.

Losing track of the servers at all is error city so I’d plan out this carefully for your setup.

I read your post and got some questions about this. When i configure mediasoup in kubernetes, do i need to have a public ip (using an ingress controller) for the mediasoup server with the port ranges exposed for rtp or as long as my peers comunicate with the same instance of the server i can have it deployed with hostNetwork and using as the listenIp? i tried deploying with hostNetwork and using the nodes ip adresss as the listen ip and when o look at firefox’s about:webrtc the ice has failed

you need to expose public IP for mediasoup server as well as set listenIp to and announcedIp to the Public IP.
this will work

I don’t know much about Kubernetes, but I actually don’t think it’s a problem for multiple docker containers to share the same host with host networking. Each mediasoup worker process will check the availability of a port before using it, so all your instances should be able to share the same port range.

I have a similar setup in production now with multiple docker containers running on the same host with host networking. Someone please let me know if I’m wrong about this!