Update coturn related parameters in .env and scripts. Remove upgrade from enterprise ha

pull/721/head
cruizba 2022-05-09 18:08:26 +02:00
parent a5ba5032bf
commit ce70a4b4db
6 changed files with 56 additions and 261 deletions

View File

@ -356,6 +356,20 @@ ELASTICSEARCH_PASSWORD=
# Documentation: https://doc-kurento.readthedocs.io/en/stable/features/logging.html
# KMS_DOCKER_ENV_GST_DEBUG=
# Coturn deployment in media nodes (Experimental)
# --------------------------
# OpenVidu PRO/Enterprise includes a default TURN/STUN deployment (Coturn).
# By default, Coturn is deployed in master nodes, but if you want to deploy
# Coturn in the media nodes, you just need to set OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=true
# Default value is OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=false
# For Coturn to work, you need at least this ports open:
# For master node you need 3478 TCP/UDP open in the master node.
# For Media nodes you need 443 TCP/UDP open in media nodes.
# More info about Coturn configuration in OpenVidu PRO/ENTERPRISE:
# - https://docs.openvidu.io/en/stable/deployment/pro/on-premises/#coturn-configuration
OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=false
# Cloudformation configuration
# --------------------------
# If you're working outside AWS ignore this section

View File

@ -156,264 +156,6 @@ replace_variable_in_new_env_file() {
[[ -n "${ENV_VARIABLE_VALUE}" ]] && sed -i "s|#${ENV_VARIABLE_NAME}=|${ENV_VARIABLE_NAME}=${ENV_VARIABLE_VALUE}|" "${OPENVIDU_PREVIOUS_FOLDER}/.env-${OPENVIDU_VERSION}"
}
upgrade_ov() {
# Search local Openvidu installation
printf '\n'
printf '\n ============================================'
printf '\n Search Previous Installation of Openvidu'
printf '\n ============================================'
printf '\n'
SEARCH_IN_FOLDERS=(
"${PWD}"
"/opt/${OPENVIDU_FOLDER}"
)
for folder in "${SEARCH_IN_FOLDERS[@]}"; do
printf "\n => Searching in '%s' folder..." "${folder}"
if [ -f "${folder}/docker-compose.yml" ]; then
OPENVIDU_PREVIOUS_FOLDER="${folder}"
printf "\n => Found installation in folder '%s'" "${folder}"
break
fi
done
[ -z "${OPENVIDU_PREVIOUS_FOLDER}" ] && fatal_error "No previous Openvidu installation found"
# Upgrade Openvidu
OPENVIDU_PREVIOUS_VERSION=$(grep 'Openvidu Version:' "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" | awk '{ print $4 }')
[ -z "${OPENVIDU_PREVIOUS_VERSION}" ] && fatal_error "Can't find previous OpenVidu version"
# In this point using the variable 'OPENVIDU_PREVIOUS_VERSION' we can verify if the upgrade is
# posible or not. If it is not posible launch a warning and stop the upgrade.
if [[ "${OPENVIDU_PREVIOUS_VERSION}" != "${OPENVIDU_UPGRADABLE_VERSION}."* ]]; then
fatal_error "You can't update from version ${OPENVIDU_PREVIOUS_VERSION} to ${OPENVIDU_VERSION}.\nNever upgrade across multiple major versions."
fi
printf '\n'
printf '\n ======================================='
printf '\n Upgrade OpenVidu Pro %s to %s' "${OPENVIDU_PREVIOUS_VERSION}" "${OPENVIDU_VERSION}"
printf '\n ======================================='
printf '\n'
ROLL_BACK_FOLDER="${OPENVIDU_PREVIOUS_FOLDER}/.old-${OPENVIDU_PREVIOUS_VERSION}"
TMP_FOLDER="${OPENVIDU_PREVIOUS_FOLDER}/tmp"
ACTUAL_FOLDER="${PWD}"
printf "\n Creating rollback folder '%s'..." ".old-${OPENVIDU_PREVIOUS_VERSION}"
mkdir "${ROLL_BACK_FOLDER}" || fatal_error "Error while creating the folder '.old-${OPENVIDU_PREVIOUS_VERSION}'"
printf "\n Creating temporal folder 'tmp'..."
mkdir "${TMP_FOLDER}" || fatal_error "Error while creating the folder 'temporal'"
# Download necessary files
printf '\n => Downloading new OpenVidu Pro files:'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/cluster/aws/openvidu_autodiscover.sh \
--output "${TMP_FOLDER}/openvidu_autodiscover.sh" || fatal_error "Error when downloading the file 'openvidu_autodiscover.sh'"
printf '\n - openvidu_autodiscover.sh'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/cluster/aws/openvidu_drop.sh \
--output "${TMP_FOLDER}/openvidu_drop.sh" || fatal_error "Error when downloading the file 'openvidu_drop.sh'"
printf '\n - openvidu_drop.sh'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/cluster/aws/openvidu_launch_kms.sh \
--output "${TMP_FOLDER}/openvidu_launch_kms.sh" || fatal_error "Error when downloading the file 'openvidu_launch_kms.sh'"
printf '\n - openvidu_launch_kms.sh'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/beats/filebeat.yml \
--output "${TMP_FOLDER}/filebeat.yml" || fatal_error "Error when downloading the file 'filebeat.yml'"
printf '\n - filebeat.yml'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/beats/metricbeat.yml \
--output "${TMP_FOLDER}/metricbeat.yml" || fatal_error "Error when downloading the file 'metricbeat.yml'"
printf '\n - metricbeat.yml'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/.env \
--output "${TMP_FOLDER}/.env" || fatal_error "Error when downloading the file '.env'"
printf '\n - .env'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/docker-compose.yml \
--output "${TMP_FOLDER}/docker-compose.yml" || fatal_error "Error when downloading the file 'docker-compose.yml'"
printf '\n - docker-compose.yml'
curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/enterprise/master-node/openvidu \
--output "${TMP_FOLDER}/openvidu" || fatal_error "Error when downloading the file 'openvidu'"
printf '\n - openvidu'
# Downloading new images and stopped actual Openvidu
printf '\n => Downloading new images...'
printf '\n'
sleep 1
printf "\n => Moving to 'tmp' folder..."
printf '\n'
cd "${TMP_FOLDER}" || fatal_error "Error when moving to 'tmp' folder"
printf '\n'
docker-compose pull || true
printf '\n => Stopping Openvidu...'
printf '\n'
sleep 1
printf "\n => Moving to 'openvidu' folder..."
printf '\n'
cd "${OPENVIDU_PREVIOUS_FOLDER}" || fatal_error "Error when moving to 'openvidu' folder"
printf '\n'
docker-compose down || true
printf '\n'
printf '\n => Moving to working dir...'
cd "${ACTUAL_FOLDER}" || fatal_error "Error when moving to working dir"
# Move old files to rollback folder
printf '\n => Moving previous installation files to rollback folder:'
mv "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous 'docker-compose.yml'"
printf '\n - docker-compose.yml'
mv "${OPENVIDU_PREVIOUS_FOLDER}/openvidu" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous 'openvidu'"
printf '\n - openvidu'
mv "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous 'cluster/aws'"
printf '\n - cluster/aws'
mv "${OPENVIDU_PREVIOUS_FOLDER}/beats" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous 'beats'"
printf '\n - beats'
cp "${OPENVIDU_PREVIOUS_FOLDER}/.env" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous '.env'"
printf '\n - .env'
if [ -d "${OPENVIDU_PREVIOUS_FOLDER}/custom-nginx-vhosts" ]; then
mv "${OPENVIDU_PREVIOUS_FOLDER}/custom-nginx-vhosts" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous directory 'custom-nginx-vhosts'"
printf '\n - custom-nginx-vhosts'
fi
if [ -d "${OPENVIDU_PREVIOUS_FOLDER}/custom-nginx-locations" ]; then
mv "${OPENVIDU_PREVIOUS_FOLDER}/custom-nginx-locations" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous directory 'custom-nginx-locations'"
printf '\n - custom-nginx-locations'
fi
# Move tmp files to Openvidu
printf '\n => Updating files:'
mv "${TMP_FOLDER}/docker-compose.yml" "${OPENVIDU_PREVIOUS_FOLDER}" || fatal_error "Error while updating 'docker-compose.yml'"
printf '\n - docker-compose.yml'
mv "${TMP_FOLDER}/.env" "${OPENVIDU_PREVIOUS_FOLDER}/.env-${OPENVIDU_VERSION}" || fatal_error "Error while moving previous '.env'"
printf '\n - .env-%s' "${OPENVIDU_VERSION}"
mv "${TMP_FOLDER}/openvidu" "${OPENVIDU_PREVIOUS_FOLDER}" || fatal_error "Error while updating 'openvidu'"
printf '\n - openvidu'
mkdir "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws" || fatal_error "Error while creating the folder 'cluster/aws'"
mkdir "${OPENVIDU_PREVIOUS_FOLDER}/beats" || fatal_error "Error while creating the folder 'beats'"
mv "${TMP_FOLDER}/openvidu_autodiscover.sh" "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws" || fatal_error "Error while updating 'openvidu_autodiscover.sh'"
printf '\n - openvidu_autodiscover.sh'
mv "${TMP_FOLDER}/openvidu_drop.sh" "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws" || fatal_error "Error while updating 'openvidu_drop.sh'"
printf '\n - openvidu_drop.sh'
mv "${TMP_FOLDER}/openvidu_launch_kms.sh" "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws" || fatal_error "Error while updating 'openvidu_launch_kms.sh'"
printf '\n - openvidu_launch_kms.sh'
mv "${TMP_FOLDER}/filebeat.yml" "${OPENVIDU_PREVIOUS_FOLDER}/beats/filebeat.yml" || fatal_error "Error while updating 'filebeat.yml'"
printf '\n - filebeat.yml'
mv "${TMP_FOLDER}/metricbeat.yml" "${OPENVIDU_PREVIOUS_FOLDER}/beats/metricbeat.yml" || fatal_error "Error while updating 'metricbeat.yml'"
printf '\n - metricbeat.yml'
printf "\n => Deleting 'tmp' folder"
rm -rf "${TMP_FOLDER}" || fatal_error "Error deleting 'tmp' folder"
# Add execution permissions
printf "\n => Adding permission to 'openvidu' program..."
chmod +x "${OPENVIDU_PREVIOUS_FOLDER}/openvidu" || fatal_error "Error while adding permission to 'openvidu' program"
printf '\n - openvidu'
# Change recording folder with all permissions
printf "\n => Adding permission to 'recordings' folder..."
mkdir -p "${OPENVIDU_PREVIOUS_FOLDER}/recordings"
chmod +x "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws/openvidu_autodiscover.sh" || fatal_error "Error while adding permission to 'openvidu_autodiscover.sh' program"
printf '\n - openvidu_autodiscover.sh'
chmod +x "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws/openvidu_drop.sh" || fatal_error "Error while adding permission to 'openvidu' openvidu_drop.sh"
printf '\n - openvidu_drop.sh'
chmod +x "${OPENVIDU_PREVIOUS_FOLDER}/cluster/aws/openvidu_launch_kms.sh" || fatal_error "Error while adding permission to 'openvidu_launch_kms.sh' program"
printf '\n - openvidu_launch_kms.sh'
# Define old mode: On Premise or Cloud Formation
OLD_MODE=$(grep -E "Installation Mode:.*$" "${ROLL_BACK_FOLDER}/docker-compose.yml" | awk '{ print $4,$5 }')
[ -n "${OLD_MODE}" ] && sed -i -r "s/Installation Mode:.+/Installation Mode: ${OLD_MODE}/" "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml"
# Update .env variables to new .env-version
AWS_REGION=$(get_previous_env_variable AWS_DEFAULT_REGION)
if [[ -n ${AWS_REGION} ]]; then
# Get new AMI ID
NEW_AMI_ID=$(curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/CF-OpenVidu-Pro-${OPENVIDU_VERSION//v}.yaml --silent |
sed -n -e '/KMSAMIMAP:/,/Metadata:/ p' |
grep -A 1 "${AWS_REGION}" | grep AMI | tr -d " " | cut -d":" -f2)
[[ -z ${NEW_AMI_ID} ]] && fatal_error "Error while getting new AWS_IMAGE_ID for Media Nodes"
# Get previous values
PREV_AWS_DEFAULT_REGION=$(get_previous_env_variable AWS_DEFAULT_REGION)
PREV_AWS_INSTANCE_TYPE=$(get_previous_env_variable AWS_INSTANCE_TYPE)
PREV_AWS_INSTANCE_ID=$(get_previous_env_variable AWS_INSTANCE_ID)
PREV_AWS_KEY_NAME=$(get_previous_env_variable AWS_KEY_NAME)
PREV_AWS_SUBNET_ID=$(get_previous_env_variable AWS_SUBNET_ID)
PREV_AWS_SECURITY_GROUP=$(get_previous_env_variable AWS_SECURITY_GROUP)
PREV_AWS_STACK_ID=$(get_previous_env_variable AWS_STACK_ID)
PREV_AWS_STACK_NAME=$(get_previous_env_variable AWS_STACK_NAME)
PREV_AWS_CLI_DOCKER_TAG=$(get_previous_env_variable AWS_CLI_DOCKER_TAG)
PREV_AWS_VOLUME_SIZE=$(get_previous_env_variable AWS_VOLUME_SIZE)
# Replace variables in new .env-version file
replace_variable_in_new_env_file "AWS_DEFAULT_REGION" "${PREV_AWS_DEFAULT_REGION}"
replace_variable_in_new_env_file "AWS_INSTANCE_TYPE" "${PREV_AWS_INSTANCE_TYPE}"
replace_variable_in_new_env_file "AWS_INSTANCE_ID" "${PREV_AWS_INSTANCE_ID}"
replace_variable_in_new_env_file "AWS_KEY_NAME" "${PREV_AWS_KEY_NAME}"
replace_variable_in_new_env_file "AWS_SUBNET_ID" "${PREV_AWS_SUBNET_ID}"
replace_variable_in_new_env_file "AWS_SECURITY_GROUP" "${PREV_AWS_SECURITY_GROUP}"
replace_variable_in_new_env_file "AWS_STACK_ID" "${PREV_AWS_STACK_ID}"
replace_variable_in_new_env_file "AWS_STACK_NAME" "${PREV_AWS_STACK_NAME}"
replace_variable_in_new_env_file "AWS_CLI_DOCKER_TAG" "${PREV_AWS_CLI_DOCKER_TAG}"
replace_variable_in_new_env_file "AWS_VOLUME_SIZE" "${PREV_AWS_VOLUME_SIZE}"
# Replace new AMI
replace_variable_in_new_env_file "AWS_IMAGE_ID" "${NEW_AMI_ID}"
fi
# Ready to use
printf '\n'
printf '\n'
printf '\n ================================================'
printf "\n Openvidu successfully upgraded to version %s" "${OPENVIDU_VERSION}"
printf '\n ================================================'
printf '\n'
printf "\n 1. A new file 'docker-compose.yml' has been created with the new OpenVidu %s services" "${OPENVIDU_VERSION}"
printf '\n'
printf "\n 2. The previous file '.env' remains intact, but a new file '.env-%s' has been created." "${OPENVIDU_VERSION}"
printf "\n Transfer any configuration you wish to keep in the upgraded version from '.env' to '.env-%s'." "${OPENVIDU_VERSION}"
printf "\n When you are OK with it, rename and leave as the only '.env' file of the folder the new '.env-%s'." "${OPENVIDU_VERSION}"
printf '\n'
printf '\n 3. Start new version of Openvidu'
printf '\n $ ./openvidu start'
printf '\n'
printf "\n If you want to rollback, all the files from the previous installation have been copied to folder '.old-%s'" "${OPENVIDU_PREVIOUS_VERSION}"
printf '\n'
printf '\n'
printf '\n'
}
# Check docker and docker-compose installation
if ! command -v docker > /dev/null; then
echo "You don't have docker installed, please install it and re-run the command"
@ -433,7 +175,7 @@ fi
# Check type of installation
if [[ -n "$1" && "$1" == "upgrade" ]]; then
upgrade_ov
fatal_error "OpenVidu Enterprise HA can't be upgraded manually. Deploy the Cloudformation template of the version '${OPENVIDU_VERSION}' you want to deploy: https://docs.openvidu.io/en/${OPENVIDU_VERSION//v}/deployment/enterprise/aws/"
else
new_ov_installation
fi

View File

@ -207,7 +207,12 @@ is_external_url() {
}
start_openvidu() {
docker-compose up -d
COTURN_IN_MEDIA_NODES=$(grep -v '^#' .env | grep COTURN_IN_MEDIA_NODES | cut -d '=' -f2)
if [[ -z "${COTURN_IN_MEDIA_NODES}" ]]; then
COTURN_IN_MEDIA_NODES=false
fi
docker-compose up -d \
$(if [ "${COTURN_IN_MEDIA_NODES}" == "false" ]; then echo '--scale coturn=0'; fi)
}
usage() {

View File

@ -221,6 +221,14 @@ Parameters:
- false
Default: true
CoturnInMediaNodes:
Description: "Choose if you want to deploy Coturn in media nodes. (Experimental)"
Type: String
AllowedValues:
- true
- false
Default: false
#start_mappings
Mappings:
OVAMIMAP:
@ -278,6 +286,7 @@ Metadata:
default: Other configuration
Parameters:
- WantToDeployDemos
- CoturnInMediaNodes
ParameterLabels:
# SSL certificate configuration
@ -330,6 +339,8 @@ Metadata:
# Other configuration
WantToDeployDemos:
default: "Deploy OpenVidu Call application"
CoturnInMediaNodes:
default: "Deploy Coturn in Media Nodes. (Experimental)"
Conditions:
WhichCertPresent: !Not [ !Equals [!Ref WhichCert, ''] ]
@ -542,6 +553,11 @@ Resources:
rm $WORKINGDIR/docker-compose.override.yml
fi
# Deploy Coturn in media nodes
if [ "${CoturnInMediaNodes}" == "true" ]; then
sed -i "s/OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=false/OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=true/" $WORKINGDIR/.env
fi
# Recording Configuration
if [ "${Recording}" != "disabled" ]; then
sed -i "s/OPENVIDU_RECORDING=false/OPENVIDU_RECORDING=true/" $WORKINGDIR/.env

View File

@ -353,6 +353,19 @@ ELASTICSEARCH_PASSWORD=
# Documentation: https://doc-kurento.readthedocs.io/en/stable/features/logging.html
# KMS_DOCKER_ENV_GST_DEBUG=
# Coturn deployment in media nodes (Experimental)
# --------------------------
# OpenVidu PRO/Enterprise includes a default TURN/STUN deployment (Coturn).
# By default, Coturn is deployed in master nodes, but if you want to deploy
# Coturn in the media nodes, you just need to set OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=true
# Default value is OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=false
# For Coturn to work, you need at least this ports open:
# For master node you need 3478 TCP/UDP open in the master node.
# For Media nodes you need 443 TCP/UDP open in media nodes.
# More info about Coturn configuration in OpenVidu PRO/ENTERPRISE:
# - https://docs.openvidu.io/en/stable/deployment/pro/on-premises/#coturn-configuration
OPENVIDU_PRO_COTURN_IN_MEDIA_NODES=false
# Cloudformation configuration
# --------------------------
# If you're working outside AWS ignore this section

View File

@ -213,8 +213,12 @@ start_openvidu() {
local CONFIGURED_KIBANA_HOST
CONFIGURED_ELASTICSEARCH_HOST=$(grep -v '^#' .env | grep OPENVIDU_PRO_ELASTICSEARCH_HOST | cut -d '=' -f2)
CONFIGURED_KIBANA_HOST=$(grep -v '^#' .env | grep OPENVIDU_PRO_KIBANA_HOST | cut -d '=' -f2)
COTURN_IN_MEDIA_NODES=$(grep -v '^#' .env | grep COTURN_IN_MEDIA_NODES | cut -d '=' -f2)
RUN_LOCAL_ES=true
RUN_LOCAL_KIBANA=true
if [[ -z "${COTURN_IN_MEDIA_NODES}" ]]; then
COTURN_IN_MEDIA_NODES=false
fi
if is_external_url "${CONFIGURED_ELASTICSEARCH_HOST}"; then
printf "Configured external elasticsearch: %s" "${CONFIGURED_ELASTICSEARCH_HOST}"
printf "\n"
@ -227,7 +231,8 @@ start_openvidu() {
fi
docker-compose up -d \
$(if [ "${RUN_LOCAL_ES}" == "false" ]; then echo '--scale elasticsearch=0'; fi) \
$(if [ "${RUN_LOCAL_KIBANA}" == "false" ]; then echo '--scale kibana=0'; fi)
$(if [ "${RUN_LOCAL_KIBANA}" == "false" ]; then echo '--scale kibana=0'; fi) \
$(if [ "${COTURN_IN_MEDIA_NODES}" == "false" ]; then echo '--scale coturn=0'; fi)
}
usage() {