大网数据广告活动
服务器运维问答

WEBRTC MCU/SFU inside kubernetes - Port Ranges?

· 52CE 我爱测

I am using janus-gateway as a webrtc media server for group videocalling. Previously I had deployed it in a single node using docker-compose but now I want to be able to scale it horizontally. For this, I am trying to use kuberne…

问题原文

原帖链接 · Abdul Basit · CC BY-SA 4.0

I am using janus-gateway as a webrtc media server for group videocalling. Previously I had deployed it in a single node using docker-compose but now I want to be able to scale it horizontally. For this, I am trying to use kubernetes but I am facing two problems:

1: Specifying port range to expose for the media server. As the media server needs a port range to operate, which I was able to do in docker-compose with following code

janus-gateway:
 build: ./gateway
 image: janus-gateway-image
 restart: always
 ports:
   -  8088:8088
   -  8188:8188
   -  7088:7088
   -  "10000-10200:10000-10200/udp"
 networks:
  - back-tier

But I am unable to find any alternative for this in kubernetes. How can I expose a port range using kubernetes.

2: How can I connect from my nodejs app to a specific instance of the gateway. so let's say two instances of gateway are running, right now when user connects to the app, I connect it to one of the two instances running and save it in the redis, and make sure any request from this user is passed to that specific instance. How can I connect to specific replica from node ? Also getting replicas list?

I have checked this issue on kuebernetes but it's still not resolved yet. Is there any workaround for this?

社区高分解答

原帖链接 · Crou · CC BY-SA 4.0

How can I expose a port range using kubernetes.

Short answer: You cannot.

To elaborate a bit more, as Yorgos Saslis mentioned here.

the problem is that - given the current state of Docker - it seems you should NOT even be trying to expose large numbers of ports. You are advised to use the host network anyway, due to the overhead involved with large port ranges. (it adds both latency, as well as consumes significant resources - e.g. see https://www.percona.com/blog/2016/02/05/measuring-docker-cpu-network-overhead/ )

I think VoIP is not something that should be implemented with Kubernetes. media servers are pretty stateful and require dynamically opening of new connections while Kubernetes is mostly* stateless.

It would greatly depend on the actual architecture You want. But I'm assuming You want to expose a single port and let K8s do the scaling and the routing with local balancing. If statefulness of port connections is required, K8s is not the solution to use.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。