Isolates Jibri pods from their Deployment when they start recording or livestreaming, and cleans them up when they finish.

Overview

jibri-pod-controller: A tool for managing the scaling of large Jibri deployments in Kubernetes.

When managing a large Jibri deployment, you usually want to autoscale using a strategy like "always keep N spare (not recording or livestreaming) jibri pods". This is difficult to achieve with the standard Kubernetes horizontal pod autoscaler (HPA).

jibri-pod-controller can be used as part of an alternative approach:

  • Deploy jibri using a Deployment. Set the Deployment's replicas to the number of spare jibri pods you want to run.
  • Deploy jibri-pod-controller in your cluster and give it RBAC permission to get/list/patch jibri pods.
  • Configure jibri in single use mode, and configure it to send webhook requests to jibri-pod-controller.
  • When a jibri pod starts to record or live-stream, jibri-pod-controller will patch the pod's labels so that they don't match the Deployment's label selector. This isolates the jibri pod from the Deployment — the Deployment will immediately launch another jibri pod to replace it (thus keeping the required number of spare pods), and the isolated jibri pod will continue to run.
  • When jibri finishes recording or live-streaming, jibri-pod-controller will delete the pod. A sweeper runs on a configurable interval to remove any expired jibri pods in case jibri fails to send the webhook for any reason. If multiple jibri-pod-controller pods are running, one is elected to run the sweeper.

Building a container image from source

git clone https://github.com/avstack/jibri-pod-controller.git
cd jibri-pod-controller
docker build .

Example

jibri.conf

Irrelevant settings have been left out.

jibri {
  id = "$POD_NAME"
  single-use-mode = true

  api {
    http {
      // This must match the JIBRI_HEALTH_PORT environment variable in the jibri-pod-controller deployment
      external-api-port = 8080
    }
  }

  webhook {
    subscribers = [
      // $POD_NAME must be substituted with the Jibri pod name, for example by using envFrom to set it as
      // an environment variable and then using envsubst on jibri.conf in the container entrypoint script.
      "http://jibri-pod-controller.default.svc.cluster.local/webhook/$POD_NAME"
    ]
  }
}

jibri-pod-controller deployment

  • Replace the image with the URL to your built container image of jibri-pod-controller.
  • In this example, the JIBRI_BUSY_LABELS are set to app=jibri,state=busy. You could set up your jibri Deployment to select app=jibri,state=idle.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: jibri-pod-controller
  namespace: default
rules:
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - list
  - patch
  - get
  - delete
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - create
- apiGroups:
  - coordination.k8s.io
  resourceNames:
  - jibri-pod-controller-lease
  resources:
  - leases
  verbs:
  - update
  - patch
  - get

---

apiVersion: v1
kind: ServiceAccount
automountServiceAccountToken: true
metadata:
  name: jibri-pod-controller
  namespace: default

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: jibri-pod-controller
  namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: jibri-pod-controller
subjects:
- kind: ServiceAccount
  name: jibri-pod-controller
  namespace: default

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jibri-pod-controller
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      app: jibri-pod-controller
  template:
    metadata:
      labels:
        app: jibri-pod-controller
    spec:
      automountServiceAccountToken: true
      serviceAccountName: jibri-pod-controller
      terminationGracePeriodSeconds: 30
      containers:
      - name: jibri-pod-controller
        image: your.image.registry.url/jibri-pod-controller:your-tag
        env:
        - name: RUST_LOG
          value: info
        - name: PORT
          value: "8080"
        - name: JIBRI_HEALTH_PORT
          value: "8080"
        - name: JIBRI_BUSY_LABELS
          value: app=jibri,state=busy
        - name: SWEEP_INTERVAL
          value: "300"
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 1
          httpGet:
            path: /
            port: http
            scheme: HTTP
          initialDelaySeconds: 3
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          requests:
            cpu: 5m
            memory: 8Mi
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          readOnlyRootFilesystem: true
      securityContext:
        runAsGroup: 1000
        runAsNonRoot: true
        runAsUser: 1000
      topologySpreadConstraints:
      - labelSelector:
          matchExpressions:
          - key: app
            operator: In
            values:
            - jibri-pod-controller
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
      - labelSelector:
          matchExpressions:
          - key: app
            operator: In
            values:
            - jibri-pod-controller
        maxSkew: 1
        topologyKey: failure-domain.beta.kubernetes.io/zone
        whenUnsatisfiable: ScheduleAnyway

---

apiVersion: v1
kind: Service
metadata:
  name: jibri-pod-controller
  namespace: default
spec:
  type: ClusterIP
  selector:
    app: jibri-pod-controller
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080

License

jibri-pod-controller is licensed under either of

at your option.

Contribution

Any kinds of contributions are welcome as a pull request.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Acknowledgements

jibri-pod-controller development is sponsored by AVStack. We provide globally-distributed, scalable, managed Jitsi Meet backends.

You might also like...
A html document syntax and operation library written in Rust, use APIs similar to jQuery.

Visdom A server-side html document syntax and operation library written in Rust, it uses apis similar to jQuery, left off the parts thoes only worked

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

A rust web framework with safety and speed in mind.

darpi A web api framework with speed and safety in mind. One of the big goals is to catch all errors at compile time, if possible. The framework uses

Markdown LSP server for easy note-taking with cross-references and diagnostics.
Markdown LSP server for easy note-taking with cross-references and diagnostics.

Zeta Note is a language server that helps you write and manage notes. The primary focus is to support Zettelkasten-like1, 2 note taking by providing an easy way to cross-reference notes (see more about features below).

Volt - A powerful, fast and memory safe package manager for the web
Volt - A powerful, fast and memory safe package manager for the web

Volt - A powerful, fast and memory safe package manager for the web

Thruster - An fast and intuitive rust web framework

A fast, middleware based, web framework written in Rust

A full-featured and easy-to-use web framework with the Rust programming language.

Poem Framework A program is like a poem, you cannot write a poem without writing it. --- Dijkstra A full-featured and easy-to-use web framework with t

Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.
Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.

Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.

Murasaki is a Fast, Secure, and Reliable Webkit based web browser.
Murasaki is a Fast, Secure, and Reliable Webkit based web browser.

Murasaki is a Fast, Secure, and Reliable Webkit based web browser. Table of Contents Goals Status Usage License Goals Security: Be secure, and not com

Comments
  • The ideas coincide

    The ideas coincide

    I have been researching jitsi-meet. Since a jibri can only record one meeting, this cannot satisfy my users. I recommend using the local-recording solution to solve it. Unfortunately, in some cases, the recording file will be lost, so I Thinking of using k8s' dynamic scaling to solve this problem, I saw this warehouse today, which was consistent with my idea, which really made me very excited. Does the recording on avstack use this solution? Will he lose the recording file? Is this a good solution?

    opened by daxiondi 2
Owner
AVStack
Deploy a globally-distributed, low-latency videoconferencing backend in seconds.
AVStack
☁ file.AsyncWrite - because THEY wont do it!!!!!! and its in RUST

☁ gm_async_write Simple module that adds file.AsyncWrite and file.AsyncAppend to Garry's Mod. These functions are mostly based off file.AsyncRead and

William 18 Dec 24, 2022
An utility to help developers manage their emails, notes and tasks effectively

nitride An admin dashboard built on Vue.js, TypeScript, Rust, and PostgreSQL. See the User Interface source code here. Requirement Rust v1.63 or great

ADEOYE Adefemi 10 Dec 27, 2022
A brief implementation of a simple hello world program in rust since they said it couldn't be done.

rust-hello-world A brief blazingly fast ?? implementation of a simple hello world program in rust since they said it couldn't be done. ?? fast ?? Also

Enoki 2 Apr 16, 2022
A Google-like web search engine that provides the user with the most relevant websites in accordance to his/her query, using crawled and indexed textual data and PageRank.

Mini Google Course project for the Architecture of Computer Systems course. Overview: Architecture: We are working on multiple components of the web c

Max 11 Aug 10, 2022
Ergonomic and modular web framework built with Tokio, Tower, and Hyper

axum axum is a web application framework that focuses on ergonomics and modularity. More information about this crate can be found in the crate docume

Tokio 7.9k Dec 31, 2022
Proxies all incoming connections to a minecraft server of your choosing, while also logging all ping and login requests to a json file and discord webhook.

minecraft-honeypot Proxies all incoming connections to a minecraft server of your choosing, while also logging all ping and login requests to a json f

Cleo 19 Jan 4, 2023
A simple authentication flow using Rust and Actix-web, with a PostgreSQL database and a sveltekit frontend.

Rust-auth-example This repository aims to represent a simple authentication flow using Rust and Actix-web, with a PostgreSQL database and a sveltekit

Kival Mahadew 4 Feb 19, 2023
A secure and efficient gateway for interacting with OpenAI's API, featuring load balancing, user request handling without individual API keys, and global access control.

OpenAI Hub OpenAI Hub is a comprehensive and robust tool designed to streamline and enhance your interaction with OpenAI's API. It features an innovat

Akase Cho 30 Jun 16, 2023
Rust Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.

Rust Embed Rust Custom Derive Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev. Y

Peter 1k Jan 5, 2023
Sōzu HTTP reverse proxy, configurable at runtime, fast and safe, built in Rust. It is awesome! Ping us on gitter to know more

Sōzu · Sōzu is a lightweight, fast, always-up reverse proxy server. Why use Sōzu? Hot configurable: Sozu can receive configuration changes at runtime

sōzu 2k Dec 30, 2022