Active-Passive Highly Availability: Janus Gateway on Kubernetes

Bugra Ozturk
3 min readMar 24, 2021


Recently, WebRTC has become more preferred because of the deficiencies in the protocol support of browser-based applications. WebRTC provides real-time communication over peer-to-peer protocol. WebRTC protocol needs two browser client to communicate. Highly Available Janus Gateway easily configured and deployed on Kubernetes cluster. In the following architecture, if any of the Kubernetes Node fails, one of any other Kubernetes Node will take all responsibility. This allows us to build an Active-Passive High Availability Clustering architecture.


Janus Gateway

Janus Gateway is one of the first applications that you can act as a client and a server at the same time. As seen in the following two figures, both architecture explained. It is an open-source application implemented by Meetecho. It provides a wide range of initiation protocol such as WebSocket and HTTP/HTTPS. In this blog, we will deploy Janus Gateway on Kubernetes with the configuration of a streaming plugin that supports stream video, audio, and data simultaneously over WebRTC. In addition, Janus has its own JavaScript library implementation that you could use in your web applications.

In Janus, each plugin has its own configuration and one for general purposes such as Real-time Transport Protocol (RTP) Port Range and NAT settings. The first configuration responsible for general configurations and the second one is responsible of Streaming Plugin configurations.

  • janus.jcfg
  • janus.plugin.streaming.jcfg

In the streaming configuration, two-room created for streaming. For more detailed configuration explanations and examples, please visit Janus Streaming Plugin Configuration Sample and Janus Configuration Sample.


Nginx is a high-performance Proxy and Load Balancer application used by a wide range of people.

Just Hint: besides UDP and TCP support, Nginx also supports higher-level load balancing like gRPC in HTTP v2.

Nginx will be used as Load Balancer. The following configuration will be mounted as Kubernetes ConfigMap on Nginx Kubernetes Deployment.

  • nginx.conf

In this configuration, assume that you have three Kubernetes Node. If you implement your own session distribution, then you can distribute without a backup option in this configuration.


In this section, all configurations will be turned into Kubernetes YAMLs. We will repeat, but we will have to convert the above configurations by fitting the Kubernetes structure for ease of deployment. Janus Gateway and Coturn servers will be deployed as Kubernetes Daemonset and Nginx will be deployed as Kubernetes Deployment. Every Kubernetes Deployment and Kubernetes Daemonset has “not-ready” and “unreachable” toleration will be 0 to Kubernetes react fast as possible.

Important Note: STUN will be used in this deployment. If your service will be served over NAT or a Firewall, you should use TURN server instead.

Janus Gateway Deployment

  • ConfigMap
  • Service
  • Deployment

Nginx Deployment

  • Configmap
  • Service
  • Deployment

Coturn Deployment

  • Service
  • Deployment

After applying these YAMLs with kubectl, we are done :)

Be careful about the installation sequence. The following sequence will be just fine.

1- Coturn

2- Janus Gateway

3- Nginx


This deployment provides us an Active-Passive Highly Available Janus Gateway cluster. With the help of Nginx Load Balancer, you can apply Active-Passive architectures to all your other applications using this methodology.

ffmpeg or gstreamer libraries could stream Video and Audio data to Janus Gateway streaming rooms. An application should be implemented to stream all three types of data at once.

This deployment could be turned into a Kubernetes Operator over HELM in the future. After Kubernetes Operator is created, this could be submitted to OperatorHub.