Customizing Kubernetes DNS using Consul

Location image of event venue

Details

At Nanit, we’re running a very large cluster of Kubernetes with lots of nginx-rtmp pods to support our customers’ live feeds of their baby’s cribs.

Running lots of nginx-rtmp pods imposes a scaling problem:
A user who’s trying to watch their baby’s Nanit camera might end up connecting to an nginx-rtmp instance while the camera is streaming to another nginx-rtmp instance. This can occur because we have our nginx-rtmp pods behind a Kubernetes service which balances the load.

To solve this, we can pull the stream from the Nginx publishing the camera’s stream to the Nginx connected to the user using nginx-rtmp’s pull method. But how do we know which Nginx instance has our stream?

This is where kube-dns and Consul come into play. We will use DNS for stream discovery. Every stream will have a DNS record and we will query our DNS service for the stream we are looking for. We will use Consul to handle our stream DNS records and will customize kube-dns to route DNS queries to Consul.