Skip to content

Commit

Permalink
Merge pull request #7 from red5pro/feature/app
Browse files Browse the repository at this point in the history
Add ability to use reserved IP for the Stream Manager Load Balancer +…
  • Loading branch information
iolesyk authored Dec 18, 2023
2 parents fc9ceef + d0ef799 commit 6d7929e
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 53 deletions.
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ In the following example, Terraform module will automates the infrastructure pro

```hcl
module "red5pro_single" {
source = "../../"
source = "red5pro/red5pro/oci"
type = "single" # Deployment type: single, cluster, autoscaling
name = "red5pro-single" # Name to be used on all the resources as identifier
ubuntu_version = "20.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
ubuntu_version = "22.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
path_to_red5pro_build = "./red5pro-server-0.0.0.b0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file
# Oracle Cloud Account Details
Expand Down Expand Up @@ -155,10 +155,10 @@ In the following example, Terraform module will automates the infrastructure pro

```hcl
module "red5pro_cluster" {
source = "../../"
source = "red5pro/red5pro/oci"
type = "cluster" # Deployment type: single, cluster, autoscaling
name = "red5pro-cluster" # Name to be used on all the resources as identifier
ubuntu_version = "20.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
ubuntu_version = "22.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
path_to_red5pro_build = "./red5pro-server-0.0.0.b0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file
path_to_terraform_cloud_controller = "./terraform-cloud-controller-0.0.0.jar" # Absolute path or relative path to Terraform Cloud Controller JAR file
path_to_terraform_service_build = "./terraform-service-0.0.0.zip"
Expand Down Expand Up @@ -186,10 +186,10 @@ module "red5pro_cluster" {
# Terraform Service configuration
terraform_service_instance_create = true
terraform_service_instance_type = "VM.Standard.E4.Flex"
terraform_service_instance_ocpu = 1
terraform_service_instance_memory = 4
terraform_service_instance_ocpu = 2
terraform_service_instance_memory = 8
terraform_service_api_key = "examplekey"
terraform_service_parallelism = 20
terraform_service_parallelism = 10
# Stream Manager HTTPS/SSL certificate configuration
https_letsencrypt_enable = true # true - create new Let's Encrypt HTTPS/SSL certificate, false - use Red5 Pro server without HTTPS/SSL certificate
Expand Down Expand Up @@ -276,10 +276,10 @@ In the following example, Terraform module will automates the infrastructure pro

```hcl
module "red5pro_autoscaling" {
source = "../../"
source = "red5pro/red5pro/oci"
type = "autoscaling" # Deployment type: single, cluster, autoscaling
name = "red5pro-autoscaling" # Name to be used on all the resources as identifier
ubuntu_version = "20.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
ubuntu_version = "22.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
path_to_red5pro_build = "./red5pro-server-0.0.0.b0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file
path_to_terraform_cloud_controller = "./terraform-cloud-controller-0.0.0.jar" # Absolute path or relative path to Terraform Cloud Controller JAR file
path_to_terraform_service_build = "./terraform-service-0.0.0.zip"
Expand All @@ -305,23 +305,29 @@ module "red5pro_autoscaling" {
# Terraform Service configuration
terraform_service_instance_type = "VM.Standard.E4.Flex"
terraform_service_instance_ocpu = 1
terraform_service_instance_memory = 4
terraform_service_instance_ocpu = 2
terraform_service_instance_memory = 8
terraform_service_api_key = "examplekey"
terraform_service_parallelism = 20
terraform_service_parallelism = 10
# Load Balancer HTTPS/SSL certificate configuration
https_oci_certificates_use_existing = false # If you want to use SSL certificate set it to true
https_oci_certificates_certificate_name = "red5pro.example.com" # Domain name for your SSL certificate
cert_fullchain = "/PATH/TO/EXISTING/SSL/CERTS/fullchain.pem"
cert_private_key = "/PATH/TO/EXISTING/SSL/CERTS/privkey.pem"
cert_public_cert = "/PATH/TO/EXISTING/SSL/CERTS/cert.pem"
https_oci_certificates_use_existing = false # If you want to use SSL certificate set it to true
https_oci_certificates_certificate_name = "red5pro.example.com" # Domain name for your SSL certificate
cert_private_key = "/PATH/TO/EXISTING/SSL/CERTS/privkey.pem" # Path to existing SSL certificate private key
cert_public_cert = "/PATH/TO/EXISTING/SSL/CERTS/cert.pem" # Path to existing SSL certificate public key
# Stream Manager configuration
stream_manager_instance_type = "VM.Standard.E4.Flex" # OCI Instance type for Stream Manager
stream_manager_instance_ocpu = 2 # OCI Instance OCPU Count for Stream Manager(1 OCPU = 2 vCPU)
stream_manager_instance_memory = 8 # OCI Instance Memory size in GB for Stream Manager
stream_manager_api_key = "examplekey" # API key for Stream Manager
stream_manager_instance_type = "VM.Standard.E4.Flex" # OCI Instance type for Stream Manager
stream_manager_instance_ocpu = 2 # OCI Instance OCPU Count for Stream Manager(1 OCPU = 2 vCPU)
stream_manager_instance_memory = 8 # OCI Instance Memory size in GB for Stream Manager
stream_manager_api_key = "examplekey" # API key for Stream Manager
stream_manager_autoscaling_desired_capacity = 1 # Desired capacity for Stream Manager autoscaling group
stream_manager_autoscaling_minimum_capacity = 1 # Min capacity for Stream Manager autoscaling group
stream_manager_autoscaling_maximum_capacity = 2 # Max capacity for Stream Manager autoscaling group
load_balancer_reserved_ip_create = true # true - create new reserved IP for Load Balancer, false - use existing reserved IP for Load Balancer
load_balancer_reserved_ip = "1.2.3.4" # Reserved IP for Load Balancer
# Red5 Pro general configuration
red5pro_license_key = "1111-2222-3333-4444" # Red5 Pro license key (https://account.red5pro.com/login)
Expand Down
32 changes: 19 additions & 13 deletions examples/autoscaling/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module "red5pro_autoscaling" {
source = "../../"
type = "autoscaling" # Deployment type: single, cluster, autoscaling
name = "red5pro-autoscaling" # Name to be used on all the resources as identifier
ubuntu_version = "20.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
ubuntu_version = "22.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
path_to_red5pro_build = "./red5pro-server-0.0.0.b0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file
path_to_terraform_cloud_controller = "./terraform-cloud-controller-0.0.0.jar" # Absolute path or relative path to Terraform Cloud Controller JAR file
path_to_terraform_service_build = "./terraform-service-0.0.0.zip"
Expand All @@ -40,23 +40,29 @@ module "red5pro_autoscaling" {

# Terraform Service configuration
terraform_service_instance_type = "VM.Standard.E4.Flex"
terraform_service_instance_ocpu = 1
terraform_service_instance_memory = 4
terraform_service_instance_ocpu = 2
terraform_service_instance_memory = 8
terraform_service_api_key = "examplekey"
terraform_service_parallelism = 20
terraform_service_parallelism = 10

# Load Balancer HTTPS/SSL certificate configuration
https_oci_certificates_use_existing = false # If you want to use SSL certificate set it to true
https_oci_certificates_certificate_name = "red5pro.example.com" # Domain name for your SSL certificate
cert_fullchain = "/PATH/TO/EXISTING/SSL/CERTS/fullchain.pem"
cert_private_key = "/PATH/TO/EXISTING/SSL/CERTS/privkey.pem"
cert_public_cert = "/PATH/TO/EXISTING/SSL/CERTS/cert.pem"
https_oci_certificates_use_existing = false # If you want to use SSL certificate set it to true
https_oci_certificates_certificate_name = "red5pro.example.com" # Domain name for your SSL certificate
cert_private_key = "/PATH/TO/EXISTING/SSL/CERTS/privkey.pem" # Path to existing SSL certificate private key
cert_public_cert = "/PATH/TO/EXISTING/SSL/CERTS/cert.pem" # Path to existing SSL certificate public key


# Stream Manager configuration
stream_manager_instance_type = "VM.Standard.E4.Flex" # OCI Instance type for Stream Manager
stream_manager_instance_ocpu = 2 # OCI Instance OCPU Count for Stream Manager(1 OCPU = 2 vCPU)
stream_manager_instance_memory = 8 # OCI Instance Memory size in GB for Stream Manager
stream_manager_api_key = "examplekey" # API key for Stream Manager
stream_manager_instance_type = "VM.Standard.E4.Flex" # OCI Instance type for Stream Manager
stream_manager_instance_ocpu = 2 # OCI Instance OCPU Count for Stream Manager(1 OCPU = 2 vCPU)
stream_manager_instance_memory = 8 # OCI Instance Memory size in GB for Stream Manager
stream_manager_api_key = "examplekey" # API key for Stream Manager
stream_manager_autoscaling_desired_capacity = 1 # Desired capacity for Stream Manager autoscaling group
stream_manager_autoscaling_minimum_capacity = 1 # Min capacity for Stream Manager autoscaling group
stream_manager_autoscaling_maximum_capacity = 2 # Max capacity for Stream Manager autoscaling group

load_balancer_reserved_ip_create = true # true - create new reserved IP for Load Balancer, false - use existing reserved IP for Load Balancer
load_balancer_reserved_ip = "1.2.3.4" # Reserved IP for Load Balancer

# Red5 Pro general configuration
red5pro_license_key = "1111-2222-3333-4444" # Red5 Pro license key (https://account.red5pro.com/login)
Expand Down
8 changes: 4 additions & 4 deletions examples/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module "red5pro_cluster" {
source = "../../"
type = "cluster" # Deployment type: single, cluster, autoscaling
name = "red5pro-cluster" # Name to be used on all the resources as identifier
ubuntu_version = "20.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
ubuntu_version = "22.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
path_to_red5pro_build = "./red5pro-server-0.0.0.b0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file
path_to_terraform_cloud_controller = "./terraform-cloud-controller-0.0.0.jar" # Absolute path or relative path to Terraform Cloud Controller JAR file
path_to_terraform_service_build = "./terraform-service-0.0.0.zip"
Expand Down Expand Up @@ -42,10 +42,10 @@ module "red5pro_cluster" {
# Terraform Service configuration
terraform_service_instance_create = true
terraform_service_instance_type = "VM.Standard.E4.Flex"
terraform_service_instance_ocpu = 1
terraform_service_instance_memory = 4
terraform_service_instance_ocpu = 2
terraform_service_instance_memory = 8
terraform_service_api_key = "examplekey"
terraform_service_parallelism = 20
terraform_service_parallelism = 10

# Stream Manager HTTPS/SSL certificate configuration
https_letsencrypt_enable = true # true - create new Let's Encrypt HTTPS/SSL certificate, false - use Red5 Pro server without HTTPS/SSL certificate
Expand Down
2 changes: 1 addition & 1 deletion examples/single/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module "red5pro_single" {
source = "../../"
type = "single" # Deployment type: single, cluster, autoscaling
name = "red5pro-single" # Name to be used on all the resources as identifier
ubuntu_version = "20.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
ubuntu_version = "22.04" # Ubuntu version to be used for machine, it can either be 20.04 or 22.04
path_to_red5pro_build = "./red5pro-server-0.0.0.b0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file

# Oracle Cloud Account Details
Expand Down
3 changes: 2 additions & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ locals {
mysql_local_enable = local.autoscaling ? false : var.mysql_db_system_create ? false : true
terraform_service_instance_create = local.autoscaling ? true : local.cluster && var.terraform_service_instance_create ? true : false
terra_host = local.autoscaling ? oci_core_instance.red5pro_terraform_service[0].private_ip : local.cluster && var.terraform_service_instance_create ? oci_core_instance.red5pro_terraform_service[0].private_ip : "localhost"
stream_manager_ip = local.autoscaling ? oci_core_public_ip.red5pro_reserved_ip[0].ip_address : local.cluster ? oci_core_instance.red5pro_sm[0].public_ip : null
stream_manager_ip = local.autoscaling ? var.load_balancer_reserved_ip_create ? oci_core_public_ip.red5pro_reserved_ip[0].ip_address : data.oci_core_public_ip.red5pro_reserved_ip[0].ip_address : local.cluster ? oci_core_instance.red5pro_sm[0].public_ip : null
ssh_private_key_path = var.ssh_key_create ? local_file.red5pro_ssh_key_pem[0].filename : var.ssh_private_key_path
ssh_public_key_path = var.ssh_key_create ? local_file.red5pro_ssh_key_pub[0].filename : var.ssh_public_key_path
ssh_private_key = var.ssh_key_create ? tls_private_key.red5pro_ssh_key[0].private_key_pem : file(var.ssh_private_key_path)
ssh_public_key = var.ssh_key_create ? tls_private_key.red5pro_ssh_key[0].public_key_openssh : file(var.ssh_public_key_path)
load_balancer_reserved_ip_id = local.autoscaling ? var.load_balancer_reserved_ip_create ? oci_core_public_ip.red5pro_reserved_ip[0].id : data.oci_core_public_ip.red5pro_reserved_ip[0].id : null
}
11 changes: 8 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,13 @@ resource "oci_core_instance" "red5pro_sm" {
################################################################################
# Red5 Pro Stream Manager Autoscaling (OCI Load Balancer + Autoscaling)
################################################################################
data "oci_core_public_ip" "red5pro_reserved_ip" {
count = local.autoscaling && var.load_balancer_reserved_ip_create == false ? 1 : 0
ip_address = var.load_balancer_reserved_ip
}

resource "oci_core_public_ip" "red5pro_reserved_ip" {
count = local.autoscaling ? 1 : 0
count = local.autoscaling && var.load_balancer_reserved_ip_create ? 1 : 0
compartment_id = var.oracle_compartment_id
lifetime = "RESERVED"

Expand All @@ -437,7 +442,7 @@ resource "oci_load_balancer_load_balancer" "red5pro_lb" {
minimum_bandwidth_in_mbps = 10
}
reserved_ips {
id = oci_core_public_ip.red5pro_reserved_ip[0].id
id = local.load_balancer_reserved_ip_id
}
}

Expand Down Expand Up @@ -489,7 +494,7 @@ resource "oci_load_balancer_listener" "red5pro_lb_listener_443" {
resource "oci_load_balancer_certificate" "red5pro_lb_ssl_cert" {
count = local.autoscaling && var.https_oci_certificates_use_existing ? 1 : 0
load_balancer_id = oci_load_balancer_load_balancer.red5pro_lb[0].id
ca_certificate = file(var.cert_fullchain)
#ca_certificate = file(var.cert_fullchain)
certificate_name = var.https_oci_certificates_certificate_name
private_key = file(var.cert_private_key)
public_certificate = file(var.cert_public_cert)
Expand Down
25 changes: 20 additions & 5 deletions red5pro-installer/r5p_config_node_apps_plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# NODE_SOCIALPUSHER_ENABLE=true
# NODE_SUPPRESSOR_ENABLE=true
# NODE_HLS_ENABLE=true
# NODE_CLOUDSTORAGE_ENABLE=true

# NODE_WEBHOOKS_ENABLE=true
# NODE_WEBHOOKS_ENDPOINT="https://test.webhook.app/api/v1/broadcast/webhook"
Expand Down Expand Up @@ -66,11 +67,10 @@ config_node_apps_plugins(){
log_e "Parameter NODE_API_KEY is empty. EXIT."
exit 1
fi
local token_pattern='security.accessToken='
local debug_logaccess_pattern='debug.logaccess=false'
local token_pattern='security.accessToken=.*'
local token_new="security.accessToken=${NODE_API_KEY}"
local debug_logaccess='debug.logaccess=true'
sed -i -e "s|$token_pattern|$token_new|" -e "s|$debug_logaccess_pattern|$debug_logaccess|" "$RED5_HOME/webapps/api/WEB-INF/red5-web.properties"

sed -i -e "s|$token_pattern|$token_new|" "$RED5_HOME/webapps/api/WEB-INF/red5-web.properties"
echo " " >> $RED5_HOME/webapps/api/WEB-INF/security/hosts.txt
echo "*" >> $RED5_HOME/webapps/api/WEB-INF/security/hosts.txt
else
Expand Down Expand Up @@ -101,10 +101,25 @@ config_node_apps_plugins(){
rm $RED5_HOME/plugins/red5pro-mpegts-plugin*
fi
fi
### Red5Pro Cloudstorage (S3)
if [[ "$NODE_CLOUDSTORAGE_ENABLE" == "true" ]]; then
log_i "Red5Pro OCI Cloudstorage plugin (S3) - enable"
log_i "HERE need to add OCI Cloudstorage configuration!!!"
else
log_d "Red5Pro OCI Cloudstorage plugin (S3) - disable"
fi
### Red5Pro Restreamer
if [[ "$NODE_RESTREAMER_ENABLE" == "true" ]]; then
log_i "Red5Pro Restreamer - enable"
log_i "HERE need to add Restreamer configuration!!!"

log_i "Enable Restreamer Servlet in $RED5_HOME/webapps/live/WEB-INF/web.xml"
restreamer_servlet="<servlet>\n<servlet-name>RestreamerServlet</servlet-name>\n<servlet-class>com.red5pro.restreamer.servlet.RestreamerServlet</servlet-class>\n</servlet>\n<servlet-mapping>\n<servlet-name>RestreamerServlet</servlet-name>\n<url-pattern>/restream</url-pattern>\n</servlet-mapping>"
sed -i "/<\/web-app>/i $restreamer_servlet" "$RED5_HOME/webapps/live/WEB-INF/web.xml"

log_i "Set enable.srtingest=true in $RED5_HOME/conf/restreamer-plugin.properties"
enable_srtingest="enable.srtingest=.*"
enable_srtingest_new="enable.srtingest=true"
sed -i -e "s|$enable_srtingest|$enable_srtingest_new|" "$RED5_HOME/conf/restreamer-plugin.properties"
else
log_d "Red5Pro Restreamer - disable"
if ls $RED5_HOME/plugins/red5pro-restreamer-plugin* >/dev/null 2>&1; then
Expand Down
Loading

0 comments on commit 6d7929e

Please sign in to comment.