Create Stream Manager 2.0 Instance
The Stream Manager 2.0 instance is the cornerstone of Red5 Pro’s architecture, providing a comprehensive solution for managing, orchestrating, and scaling your streaming infrastructure.
Stream Manager 2.0 instance consists of multiple Docker containers (microservices) and runs using Docker Compose.
Create Stream Manager 2.0 Instance
- Navigate to the Google Cloud Console.(https://console.cloud.google.com/)
- Go to Compute Engine in the left-hand navigation and click on VM Instances.
- Click the Create an Instance button to create a new virtual machine.
- Specify a name for the instance, such as
red5pro-sm-instance
. - Select the Region and Zone for the instance, for example,
us-central1
andus-central1-a
. - Choose the Machine Type, e.g.,
e2-standard-4
(4 vCPUs, 16 GB RAM). - In the Boot disk section, select Ubuntu and choose Ubuntu 22.04 LTS as the operating system image,then enter Size value as
16GB
finally click on Select button. - In the Service Account section, select an existing account created in the previous step and “Allow full access to all Cloud APIs” to grant the instance full API access.
- In the Firewalls section click on checkboxes both Allow
HTTP
andHTTPS
traffic. - Under Advanced options → Networking → In the Network interfaces section, select created VPC in the previous step
red5pro-sm-network
- In Network service Tier, Select
Standard
- Click Create to launch the instance.
Create new DNS record for Stream Manager 2.0 Instance
The default configuration requires creating a DNS record and using an SSL certificate on the Stream Manager 2.0 to allow clients to publish and subscribe to WebRTC streams using a browser.
- Find the public IP address of your Stream Manager 2.0 instance.
- Create an A record in your DNS provider to point the DNS name to the public IP address.
red5pro-sm2.example.com - 1.2.3.4
If you choose not to install a domain name and SSL certificate, you will not be able to publish WebRTC streams. However, you will still be able to publish RTMP and RTSP streams and subscribe to WebRTC, RTMP, and RTSP streams. In this case, you will need to use the docker-compose.yml file that does not include SSL certificate configuration. Example: autoscaling-without-ssl
Install Stream Manager 2.0 Instance
-
Connect to your instance over ssh as ubuntu user. Example:
ssh -i ssh_private_key.pem ubuntu@1.2.3.4
-
Install
docker
withdocker-compose-plugin
, follow the public documentation. -
Create folder for Stream Manager 2.0 files.
sudo mkdir /usr/local/stream-manager
- Pull Stream Manager 2.0 docker-compose examples from our public repository red5pro-stream-manager-2-examples.
git clone https://github.com/red5pro/red5pro-stream-manager-2-examples.git
- Choose one deployment type from examples. Example with SSL ceritificate:
autoscaling-with-ssl
- Copy files from folder
autoscaling-with-ssl
to the folder/usr/local/stream-manager
sudo cp -r ./red5pro-stream-manager-2-examples/autoscaling-with-ssl/. /usr/local/stream-manager/
- Go to the Stream Manager folder
cd /usr/local/stream-manager/
- Create folder for SSL certificate
sudo mkdir /usr/local/stream-manager/letsencrypt
- Rename docker compose variables file
sudo mv /usr/local/stream-manager/.example.env /usr/local/stream-manager/.env
- Set main Stream Manager 2.0 variables in the file
/usr/local/stream-manager/.env
R5AS_AUTH_SECRET=<SECRET_KEY>
R5AS_AUTH_USER=<USER_NAME>
R5AS_AUTH_PASS=<PASSWORD>
R5AS_CLOUD_PLATFORM_TYPE=<PLATFORM_TYPE>
KAFKA_HOST=<PRIVATE_IP>
TRAEFIK_HOST=<DNS_NAME>
TRAEFIK_SSL_EMAIL=<EMAIL>
R5P_LICENSE_KEY=<LICENSE_KEY>
R5AS_AUTH_SECRET
– Authentication secret used to create and authenticate JWTs. Example:12345abcd
R5AS_AUTH_USER
– Authentication user name used to get JWT token. Example:admin
R5AS_AUTH_PASS
– Authentication user password used to get JWT token. Example:password
R5AS_CLOUD_PLATFORM_TYPE
– Cloud platform type (GCP,OCI,AWS,LINODE). Example:GCP
KAFKA_HOST
– Kafka server IP address. In this deployment Kafka server on the Stream Manager 2.0 instance so you will need to set Private IP address of this instance. Example:10.0.0.10
TRAEFIK_HOST
– Stream Manager 2.0 domain name: This should be the same domain name you used to create the DNS record. Example:red5pro-sm2.example.com
TRAEFIK_SSL_EMAIL
– The email address that will be used for the SSL certificate.R5P_LICENSE_KEY
– Red5 Pro license key which will be using on the Red5 Pro nodes. It should be active Red5 Pro license key, Startup Pro level or higher.
- Set GCP Cloud specific variables in the
/usr/local/stream-manager/docker-compose.yml
file.
TF_VAR_project_id: "example-testing"
You should have these variables from the previous steps.
TF_VAR_project_id
– Google Cloud Project ID.Follow the docs to create
Example as-terraform
service configuration for GCP
as-terraform:
deploy:
replicas: 1
image: red5pro/as-terraform:latest
depends_on:
kafka0:
condition: service_healthy
environment:
R5AS_AUTOSCALE_PARTITIONS: 2
R5AS_REPLICATION_FACTOR: 1
R5AS_BOOTSTRAP_SERVERS: kafka0:29092
R5AS_SECURITY_PROTOCOL_CONFIG: ""
R5AS_SSL_KEYSTORE_TYPE_CONFIG: ""
R5AS_SSL_TRUSTSTORE_TYPE_CONFIG: ""
R5AS_SSL_CA_CERTIFICATE: ""
R5AS_SASL_USERNAME: ""
R5AS_SASL_PASSWORD: ""
R5AS_SASL_ENABLED_MECHANISMS: ""
R5AS_COMMAND_INACTIVITY_GAP_MS: 10000
TF_VAR_project_id: "example-testing"
TF_VAR_r5p_license_key: ${R5P_LICENSE_KEY:?R5P_LICENSE_KEY is not set}
- Start/Stop Stream Manager 2.0 – docker compose
sudo docker compose up -d
– Start the Docker Compose services defined in the docker-compose.yml file in detached mode.sudo docker compose up
– Start the Docker Compose services defined in the docker-compose.yml file.sudo docker compose logs -f
– Follow the logs of all running services in real-time.sudo docker compose down
– Stop and remove all the services defined in thedocker-compose.yml
file.
To run Docker Compose commands, you should be in the directory containing the docker-compose.yml file. In this case, it is the /usr/local/stream-manager directory.
- Create service to allow for ease of startup/shutdown of Stream Manager 2.0, in addition to automatically starting the service on server reboot, you will want to add a systemd unit file for Stream Manager 2.0.
- Create a service file:
sudo nano /lib/systemd/system/sm.service
- Add the following content to the service file:
[Unit]
Description=Stream Manager 2.0
Requires=docker.service
After=docker.service
StartLimitIntervalSec=60
[Service]
WorkingDirectory=/usr/local/stream-manager
ExecStart=/usr/bin/docker compose up
ExecStop=/usr/bin/docker compose down
TimeoutStartSec=0
Restart=on-failure
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
- Start the service:
sudo systemctl start sm.service
- Stop the service:
sudo systemctl stop sm.service
- Restart the service:
sudo systemctl restart sm.service
- Enable the service to start on boot:
sudo systemctl enable sm.service
- Check the status of the service:
sudo systemctl status sm.service
- Verify Stream Manager 2.0
To verify that the Stream Manager 2.0 is running correctly, open your web browser and navigate to the following URL: https://<STREAM_MANAGER_DOMAIN_NAME>
. If you are using the Stream Manager 2.0 without an SSL certificate and domain name, use http://<STREAM_MANAGER_IP_ADDRESS>
instead.
You should see the Stream Manager 2.0 interface if everything is set up correctly.