Skip to content

Setting Up Flussonic in Kubernetes

In this article, we will go over a simple example of the Flussonic configuration required to run Flussonic in a Kubernetes environment. You don't need to have a deep knowledge of Kubernetes or be aware of how to use it. After finishing this tutorial, you will learn:

  • two ways to deploy Flussonic in a Kubernetes environment:
    • with cloud-based Kubernetes on DigitalOcean
    • with local Kubernetes in Docker Desktop
  • create your first Pod

Flussonic has various features for working in Kubernetes. In this document we will run a basic example to show you how to use some of them.

This document is relevant both for those who are new to Kubernetes and are willing to test Flussonic in this environment as well as for those who are already actively using Kubernetes in their business.

It is assumed that you have experience with Docker, DigitalOcean and Flussonic Media Server.

Note

This document does not cover the basics of Kubernetes, its configuration and usage. Refer to Kubernetes Overview and Getting Started to learn the essential Kubernetes terms and concepts.

Glossary

This glossary is intended for those who are unfamiliar with Kubernetes and are just beginning their acquaintance with it. We will try to explain some Kubernetes terms and concepts to you so that you can look at them from a different perspective:

  • Kubernetes (also known as k8s) is a cluster management program, a set of standards and rules that allows to manage a complex and dynamic cluster of microservices in a unified way. You could say that Kubernetes is a cluster operating system.
  • Node — a worker machine (physical or virtual) in a Kubernetes cluster that executes containers.
  • Pod — is an instance of a program running in the Kubernetes OS. This program may consist of one or more containers. Pod is the smallest deployable unit of the Kubernetes ecosystem. A Pod is a group of one or more containers running on nodes in a Kubernetes cluster. This program may consist of one or more containers.
  • Deployment — object which declares the deployment type in Kubernetes. It makes sure that Kubernetes is running the required number of identical Pods. So, if you wanted to run multiple Pods, without Deployment you would have to manually define each Pod. Deployment is used to run stateless applications, that is, applications with no state tracking. Pods in Deployment are ephemeral, i.e. impermanent. This means that if a Pod is dropped and stops working, a new Pod will be started instead and it will not know anything about the Pod after which it was started. In Deployment Pods are interchangeable.
  • StatefulSet — object which declares the deployment type in Kubernetes. It also makes sure that Kubernetes runs the required number of uniform Pods. Its difference from Deployment is that StatefulSet ensures that each Pod is unique. In StatefulSet Pods have their own unique identifiers and launch order. StatefulSet ensures that each Pod has its own domain name and persistent storage. Thus, Pods are not interchangeable. StatefulSet implies that the same domain name is assigned to a Pod regardless of the number of Pod restarts. Knowing the uniqueness of a running Pod for a large number of Pods in a cluster is extremely useful. In the context of a Flussonic StatefulSet, this means that a Flussonic instance will be running with its own license key, on its own domain name, and with its own configuration.
  • Volume — a catalog mounted in the Pod container.
  • PersistentVolume — a disk space used to store data. PersistentVolume's (also referred to as PV) lifecycle is independent of that of a Pod using it. Therefore, if a cluster crashes, PV survives. In terms of Flussonic, PersistentVolume is great for recording and storing the archive. In the case of the cloud, cloud storage is provided as PersistentVolume. In the case of hosted servers, PersistentVolumes are disks on a particular node.
  • PersistentVolumeClaim — Pod request mechanism on PersistentVolume. PersistentVolumeClaims (also referred to as PVC) are specified in the same place as Pods. A Pod requests the storage through the PVC. Then PVC attempts to find suitable storage in a cluster.
  • ConfigMap — a type of volume containing non-confidential data in key-value pairs. In terms of Flussonic, ConfigMap stores the static Flussonic configuration. ConfigMap can be defined as a file on disk or through environment variables.
  • Secret — a type of volume (storage) containing confidential data, such as a username, a password, a license activation key, etc. In terms of Flussonic, Secret stores the edit_auth data: administrator login and password. Secret can be defined as a file on disk or through environment variables. Unlike ConfigMap, data in Secret is securely hidden.
  • Service is an object that allows you to aggregate many Pods in one place at once. It gives access via a single entry point for different Pods. With Service you gain access to the Pod group.

Example with DigitalOcean

Here we will walk you through the steps to deploy your first Flussonic Pod in Kubernetes environment with DigitalOcean.

Caution

The example in this article is for learning purposes only and is by no means suitable for production.

Prerequisites

To follow this guide, you need to:

Step 1. Clone the repository to your local machine

Go to our public git repository and clone it to your local machine. There we have prepared all the necessary files for you to start.

Step 2. Access your DigitalOcean account with a token

To get access to your DigitalOcean account, run the following command in the terminal:

doctl auth init -t YOUR_TOKEN

where YOUR_TOKEN is your DigitalOcean access token.

Step 3. Create a Kubernetes cluster with a Pod

To create a Kubernetes cluster with a Pod:

  1. Run the ./start.sh script in the terminal.
  2. The system will request your Flussonic license key. Provide the active license key and press Enter.

As a result of the script execution, you will have:

  • a publish-01 cluster
  • Secret object with your license key
  • a Flussonic Pod with the default edit_auth and Flussonic settings*

Caution

Flussonic starts with the default admin login root and password password. We strongly recommend you to change the these settings before accessing the Pod through public IP. See how to change the default login and password and about the Flussonic Media Server configuration in Kubernetes in About the Flussonic Pod configuration file section.

Step 4. Check the state of your Flussonic Pod

To display the information about the state of the Flussonic Pod, run the following command:

kubectl get service/flussonic

You should get something like this:

NAME        TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)                       AGE
flussonic   LoadBalancer   10.245.165.235   132.45.123.101   80:31626/TCP,1935:32726/TCP   3m32s

You will need the EXTERNAL-IP for the next step.

Step 5. Open the UI

Open the UI in your browser, using the External-IP that you received in the previous step. Sign in with root login and password password to your Flussonic server and make sure that you have it up and running with the provided configuration.

Congratulations, you've created your first Flussonic Pod in the Kubernetes environment with Digital Ocean!

Step 6. Stop the Pod

To stop the Pod and remove the Kubernetes cluster and all of its files, run the ./stop.sh script in the terminal.

Example with Docker Desktop

Here we will walk you through the steps to deploy your first Flussonic Pod in Kubernetes environment with Docker Desktop.

Prerequisites

To follow this guide, you need to:

  • Install Docker Desktop. Docker Desktop is a desktop application for local machines for the building and sharing of containerized applications and microservices. Docker Desktop has built-in minikube and kubectl. minikube is a command-line tool for creating and managing a single-node Kubernetes cluster on your local machine. kubectl is a command-line tool to manage Kubernetes clusters.
  • Have an active Flussonic license.

Step 1. Clone the repository to your local machine

Go to our public git repository and clone it to your local machine. There we have prepared all the necessary files for you to start.

Step 2. Create a Kubernetes cluster

To create a Kubernetes cluster in Docker Desktop:

  1. Open the Docker Desktop.
  2. From the Docker Dashboard, select the Setting icon.
  3. Select Kubernetes from the left sidebar and select the checkbox next to Enable Kubernetes.
  4. Click the Apply & Restart button to save the settings, then click Install to confirm. This initiates the creation of your Kubernetes cluster on your local machine.

As soon as the process is finished, you are allowed to use kubectl tool to manage your cluster.

Step 3. Create a Secret with your license key

To create a Secret with your license key, open the terminal and run the following command:

kubectl create secret generic flussonic-license --from-literal=license_key="YOUR_LICENSE_KEY"

where YOUR_LICENSE_KEY is your active Flussonic license key.

Step 4. Apply the configuration for a Pod

To apply the configuration for a Flussonic Pod with the default settings, run the following command:

kubectl apply -f publish.yaml

Caution

Flussonic starts with the default admin login root and password password. We strongly recommend you to change the these settings before accessing the Pod through public IP. See more about the Flussonic Media Server configuration in Kubernetes and publish.yaml config file in About the Flussonic Pod configuration file section.

Step 5. Check the state of your Flussonic Pod

To display the information about the state of the Flussonic Pod, run the following command:

kubectl get service/flussonic

You should get something like so:

NAME        TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)                       AGE
flussonic   LoadBalancer   10.245.165.235   132.45.123.101   80:31626/TCP,1935:32726/TCP   3m32s

You will need the EXTERNAL-IP for the next step.

Step 6. Open the UI

Open the UI in your browser using the External IP (localhost). Sign in with root login and password password to your Flussonic account and make sure that you have your Flussonic Media Server up and running with the provided configuration.

Congratulations, you've created your first Flussonic Pod in the Kubernetes environment with Docker Desktop!

About the Flussonic Pod configuration file

Flussonic uses the data provided in the environment variables of the env field in the Pod configuration file publish.yaml to start. When it comes to sensitive data like admin login and password (edit_auth in Flussonic), Kubernetes recommends placing this information to the Secrets in Base64 strings. Credentials are pulled from the Secret to the environment (env field).


kind: Secret
metadata:
  name: test-secret
data:
# root:password
  edit_auth: cm9vdDpwYXNzd29yZA==

In order to start a Pod with your personal settings you should replace the default root:password values in the edit_auth variable with your Base64-formatted login and password.

The concepts of the configuration file for Flussonic Media Server and Kubernetes differ greatly. Kubernetes allows the creation of a Flussonic configuration file (flussonic.conf) from a directory of config files. Each of these config files represents a meaningful part of the Flussonic configuration file (flussonic.conf). Let's see how it is done.


kind: ConfigMap
metadata:
  name: streamer-presets
data:
  ports: |
    rtmp 1935;
  vod: |
    file vod {
      storage /opt/flussonic/priv;
    }
  publish: |
    template pub {
      prefix pub;
      url publish://;
    }

Here you can see the ConfigMap object (kind: ConfigMap) and with the Flussonic configuration in the data field. The configuration is broken down into multiple config parts (ports, vod, and publish). Replace the data in these config parts with your own if necessary. You can also specify the parts into which the configuration is divided.
Then the config parts are referenced in the volumes -> configMap field in the items section.


volumes:
      - name: config-templates
        configMap:
          name: streamer-presets
          items:
          - key: ports
            path: ports.conf
          - key: vod
            path: vod.conf
          - key: publish
            path: publish.conf

Each part is written in a separate .conf file and placed further in the directory of config files /etc/flussonic/flussonic.conf.d.