From 559ae0f6c49ba808fce431dc18657907b9845807 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 25 Mar 2024 12:55:03 +0300 Subject: [PATCH 01/10] Add Antmedia Azure ARM Autoscale Template --- .../antmedia-azure-autoscale.yaml | 757 ++++++++++++++++++ 1 file changed, 757 insertions(+) create mode 100644 azure-arm-template/antmedia-azure-autoscale.yaml diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml new file mode 100644 index 00000000..e846b4f5 --- /dev/null +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -0,0 +1,757 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "projectName": { + "defaultValue": "antmedia-cluster", + "type": "String" + }, + "OriginInstanceCapacity": { + "type": "int", + "defaultValue": 1, + "metadata": { + "description": "Number of VM instances (100 or less)." + }, + "minValue": 1, + "maxValue": 100 + }, + "OriginInstanceType": { + "type": "string", + "defaultValue": "Standard_D2s_v3", + "metadata": { + "description": "Size of Origin VMs in the VM Scale Set." + } + }, + "EdgeInstanceCapacity": { + "type": "int", + "defaultValue": 2, + "metadata": { + "description": "Number of VM instances (100 or less)." + }, + "minValue": 1, + "maxValue": 100 + }, + "EdgeInstanceType": { + "type": "string", + "defaultValue": "Standard_D2s_v3", + "metadata": { + "description": "Type of Edge VMs in the VM Scale Set." + } + }, + "MongoDBInstanceType": { + "defaultValue": "Standard_D2s_v3", + "type": "String", + "metadata": { + "description": "The instance type of the MongoDB Instance" + } + }, + "certData": { + "type": "securestring", + "metadata": { + "description": "Base-64 encoded form of the .pfx file" + } + }, + "certPassword": { + "type": "securestring", + "metadata": { + "description": "Password for .pfx certificate" + } + }, + "InstanceUsername": { + "type": "String", + "metadata": { + "description": "Username for the Virtual Machine." + } + }, + "authenticationType": { + "defaultValue": "password", + "allowedValues": [ + "sshPublicKey", + "password" + ], + "type": "String", + "metadata": { + "description": "Type of authentication to use on the Virtual Machine. SSH key is recommended." + } + }, + "InstancePassword": { + "type": "SecureString", + "metadata": { + "description": "SSH Key or password for the Virtual Machine. SSH key is recommended." + } + } + }, + "variables": { + "publicIPAddressName": "[concat(parameters('projectName'), '-ip')]", + "appGwPublicIPAddressName": "app-gw-ip", + "osDiskType": "Standard_LRS", + "applicationGateWayName": "antmedia-app-gw", + "virtualNetworks_antmedia_cluster_vnet_name": "antmedia-cluster-vnet", + + "linuxConfiguration": { + "disablePasswordAuthentication": true, + "ssh": { + "publicKeys": [ + { + "path": "[format('/home/{0}/.ssh/authorized_keys', parameters('InstanceUsername'))]", + "keyData": "[parameters('InstancePassword')]" + } + ] + } + } + }, + "resources": [ + { + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2023-09-01", + "name": "[variables('virtualNetworks_antmedia_cluster_vnet_name')]", + "location": "[resourceGroup().location]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "10.0.0.0/16" + ] + }, + "encryption": { + "enabled": false, + "enforcement": "AllowUnencrypted" + }, + "subnets": [ + { + "name": "origin", + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]", + "properties": { + "addressPrefixes": [ + "10.0.1.0/24" + ], + "delegations": [], + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled" + }, + "type": "Microsoft.Network/virtualNetworks/subnets" + }, + { + "name": "edge", + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]", + "properties": { + "addressPrefixes": [ + "10.0.2.0/24" + ], + "delegations": [], + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled" + }, + "type": "Microsoft.Network/virtualNetworks/subnets" + }, + { + "name": "app-gw", + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'app-gw')]", + "properties": { + "addressPrefixes": [ + "10.0.0.0/24" + ], + "delegations": [], + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled" + }, + "type": "Microsoft.Network/virtualNetworks/subnets" + } + ], + "virtualNetworkPeerings": [], + "enableDdosProtection": false + } + }, + { + "type": "Microsoft.Network/networkSecurityGroups", + "apiVersion": "2020-05-01", + "name": "MongoDB-Security-Group", + "location": "[resourceGroup().location]", + "properties": { + "securityRules": [ + { + "name": "ssh_rule", + "properties": { + "description": "Locks inbound down to ssh default port 22.", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "22", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 100, + "direction": "Inbound" + } + }, + { + "name": "mongodb_rule", + "properties": { + "description": "Locks inbound down to MongoDB default port 27017.", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "27017", + "sourceAddressPrefix": "10.0.0.0/16", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 101, + "direction": "Inbound" + } + } + ] + } + }, + { + "type": "Microsoft.Network/networkSecurityGroups", + "apiVersion": "2020-05-01", + "name": "AMSScaleSet-Security-Group", + "location": "[resourceGroup().location]", + "properties": { + "securityRules": [ + { + "name": "ssh_rule", + "properties": { + "description": "Locks inbound down to ssh default port 22.", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "22", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 100, + "direction": "Inbound" + } + }, + { + "name": "cluster_rule1", + "properties": { + "description": "Locks inbound down to Cluster default port 5000.", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "5000", + "sourceAddressPrefix": "10.0.0.0/16", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 101, + "direction": "Inbound" + } + }, + { + "name": "cluster_rule2", + "properties": { + "description": "Locks inbound down to Cluster default port 5000.", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "5000", + "sourceAddressPrefix": "10.0.0.0/16", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 102, + "direction": "Inbound" + } + }, + { + "name": "cluster_rule3", + "properties": { + "description": "Locks inbound down to Cluster default port 5080.", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "5080", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 103, + "direction": "Inbound" + } + }, + { + "name": "cluster_rule4", + "properties": { + "description": "Locks inbound down to Cluster default port 50000-60000.", + "protocol": "Udp", + "sourcePortRange": "*", + "destinationPortRange": "50000-60000", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 104, + "direction": "Inbound" + } + } + ] + } + }, + { + "type": "Microsoft.Network/publicIPAddresses", + "name": "[variables('appGwPublicIPAddressName')]", + "location": "[resourceGroup().location]", + "apiVersion": "2020-06-01", + "sku": { + "name": "Standard" + }, + "properties": { + "publicIPAllocationMethod": "Static" + } + }, + { + "type": "Microsoft.Network/publicIPAddresses", + "apiVersion": "2020-05-01", + "name": "[variables('publicIPAddressName')]", + "location": "[resourceGroup().location]", + "sku": { + "name": "Basic" + }, + "properties": { + "publicIPAllocationMethod": "Dynamic" + } + }, + { + "type": "Microsoft.Network/virtualNetworks/subnets", + "apiVersion": "2023-09-01", + "name": "[concat(variables('virtualNetworks_antmedia_cluster_vnet_name'), '/app-gw')]", + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]" + ], + "properties": { + "addressPrefixes": [ + "10.0.0.0/24" + ], + "delegations": [], + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled" + } + }, + { + "type": "Microsoft.Network/virtualNetworks/subnets", + "apiVersion": "2023-09-01", + "name": "[concat(variables('virtualNetworks_antmedia_cluster_vnet_name'), '/edge')]", + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]" + ], + "properties": { + "addressPrefixes": [ + "10.0.2.0/24" + ], + "delegations": [], + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled" + } + }, + { + "type": "Microsoft.Network/virtualNetworks/subnets", + "apiVersion": "2023-09-01", + "name": "[concat(variables('virtualNetworks_antmedia_cluster_vnet_name'), '/origin')]", + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworks_antmedia_cluster_vnet_name'))]" + ], + "properties": { + "addressPrefixes": [ + "10.0.1.0/24" + ], + "delegations": [], + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled" + } + }, + { + "type": "Microsoft.Network/applicationGateways", + "apiVersion": "2021-05-01", + "name": "[variables('applicationGateWayName')]", + "location": "[resourceGroup().location]", + "properties": { + "sku": { + "name": "Standard_v2", + "tier": "Standard_v2" + }, + "sslCertificates": [ + { + "name": "appGatewaySslCert", + "properties": { + "data": "[parameters('certData')]", + "password": "[parameters('certPassword')]" + } + } + ], + "gatewayIPConfigurations": [ + { + "name": "appGatewayIpConfig", + "properties": { + "subnet": { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'app-gw')]" + } + } + } + ], + "frontendIPConfigurations": [ + { + "name": "appGwPublicFrontendIp", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('appGwPublicIPAddressName'))]" + } + } + } + ], + "frontendPorts": [ + { + "name": "port_443", + "properties": { + "port": 443 + } + }, + { + "name": "port_5443", + "properties": { + "port": 5443 + } + } + ], + "backendAddressPools": [ + { + "name": "OriginBackendPool", + "properties": {} + }, + { + "name": "EdgeBackendPool", + "properties": {} + } + ], + "backendHttpSettingsCollection": [ + { + "name": "myHTTPSetting", + "properties": { + "port": 5080, + "protocol": "Http", + "cookieBasedAffinity": "Disabled", + "pickHostNameFromBackendAddress": false, + "requestTimeout": 20 + } + } + ], + "httpListeners": [ + { + "name": "443Listener", + "properties": { + "frontendIPConfiguration": { + "id": "[resourceId('Microsoft.Network/applicationGateways/frontendIPConfigurations', variables('applicationGateWayName'), 'appGwPublicFrontendIp')]" + }, + "frontendPort": { + "id": "[resourceId('Microsoft.Network/applicationGateways/frontendPorts', variables('applicationGateWayName'), 'port_443')]" + }, + "Protocol": "Https", + "SslCertificate": { + "Id": "[resourceId('Microsoft.Network/applicationGateways/sslCertificates',variables('applicationGatewayName'), 'appGatewaySslCert')]" + } + } + }, + { + "name": "5443Listener", + "properties": { + "frontendIPConfiguration": { + "id": "[resourceId('Microsoft.Network/applicationGateways/frontendIPConfigurations', variables('applicationGateWayName'), 'appGwPublicFrontendIp')]" + }, + "frontendPort": { + "id": "[resourceId('Microsoft.Network/applicationGateways/frontendPorts', variables('applicationGateWayName'), 'port_5443')]" + }, + "Protocol": "Https", + "SslCertificate": { + "Id": "[resourceId('Microsoft.Network/applicationGateways/sslCertificates',variables('applicationGatewayName'), 'appGatewaySslCert')]" + } + } + } + ], + "requestRoutingRules": [ + { + "name": "443RoutingRule", + "properties": { + "ruleType": "Basic", + "httpListener": { + "id": "[resourceId('Microsoft.Network/applicationGateways/httpListeners', variables('applicationGateWayName'), '443Listener')]" + }, + "backendAddressPool": { + "id": "[resourceId('Microsoft.Network/applicationGateways/backendAddressPools', variables('applicationGateWayName'), 'OriginBackendPool')]" + }, + "backendHttpSettings": { + "id": "[resourceId('Microsoft.Network/applicationGateways/backendHttpSettingsCollection', variables('applicationGateWayName'), 'myHTTPSetting')]" + } + } + }, + { + "name": "5443RoutingRule", + "properties": { + "ruleType": "Basic", + "httpListener": { + "id": "[resourceId('Microsoft.Network/applicationGateways/httpListeners', variables('applicationGateWayName'), '5443Listener')]" + }, + "backendAddressPool": { + "id": "[resourceId('Microsoft.Network/applicationGateways/backendAddressPools', variables('applicationGateWayName'), 'EdgeBackendPool')]" + }, + "backendHttpSettings": { + "id": "[resourceId('Microsoft.Network/applicationGateways/backendHttpSettingsCollection', variables('applicationGateWayName'), 'myHTTPSetting')]" + } + } + } + ], + "enableHttp2": false, + "autoscaleConfiguration": { + "minCapacity": 0, + "maxCapacity": 10 + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/publicIPAddresses', variables('appGwPublicIPAddressName'))]", + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'app-gw')]" + ] + }, + { + "type": "Microsoft.Compute/virtualMachines", + "apiVersion": "2023-09-01", + "name": "antmedia-mongodb", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]", + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]" + ], + "properties": { + "hardwareProfile": { + "vmSize": "[parameters('MongoDBInstanceType')]" + }, + "storageProfile": { + "osDisk": { + "createOption": "FromImage", + "managedDisk": { + "storageAccountType": "[variables('osDiskType')]" + } + }, + "imageReference": { + "publisher": "Canonical", + "offer": "0001-com-ubuntu-server-jammy", + "sku": "22_04-lts-gen2", + "version": "latest" + } + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', 'antmedia-mongodb-NIC')]" + } + ] + }, + "osProfile": { + "computerName": "antmedia-mongodb", + "adminUsername": "[parameters('InstanceUsername')]", + "adminPassword": "[parameters('InstancePassword')]", + "linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), null(), variables('linuxConfiguration'))]", + "customData": "[base64('#!/bin/bash\nwget -O install_mongodb.sh https://raw.githubusercontent.com/ant-media/Scripts/master/install_mongodb.sh\nchmod +x install_mongodb.sh\n./install_mongodb.sh')]" + + } + } + }, + { + "type": "Microsoft.Network/networkInterfaces", + "apiVersion": "2023-09-01", + "name": "antmedia-mongodb-NIC", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworks_antmedia_cluster_vnet_name'))]" + ], + "properties": { + "ipConfigurations": [ + { + "name": "antmedia-mongodb-IPConfig", + "properties": { + "privateIPAllocationMethod": "Static", + "privateIPAddress": "10.0.1.99", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" + }, + "subnet": { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]" + } + } + } + ], + "networkSecurityGroup": { + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', 'MongoDB-Security-Group')]" + } + } + }, + { + "type": "Microsoft.Compute/virtualMachineScaleSets", + "apiVersion": "2023-03-01", + "name": "antmedia-origin", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]", + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]", + "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]" + + ], + "sku": { + "name": "[parameters('OriginInstanceType')]", + "tier": "Standard", + "capacity": "[parameters('OriginInstanceCapacity')]" + }, + "plan": { + "name": "enterprise_edition", + "product": "ant_media_server_enterprise", + "publisher": "antmedia" + }, + "properties": { + "platformFaultDomainCount": 1, + "singlePlacementGroup": false, + "orchestrationMode": "Flexible", + "virtualMachineProfile": { + "osProfile": { + "computerNamePrefix": "antmedia-", + "adminUsername": "[parameters('InstanceUsername')]", + "adminPassword": "[parameters('InstancePassword')]", + "linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), null(), variables('linuxConfiguration'))]", + "customData": "[base64('#!/bin/bash\nsudo sed -i \"/org.apache.catalina.valves.RemoteIpValve/d\" /usr/local/antmedia/conf/jee-container.xml\n/usr/local/antmedia/change_server_mode.sh cluster 10.0.1.99')]" + }, + "storageProfile": { + "osDisk": { + "createOption": "FromImage", + "managedDisk": { + "storageAccountType": "Premium_LRS" + } + }, + "imageReference": { + "publisher": "antmedia", + "offer": "ant_media_server_enterprise", + "sku": "enterprise_edition", + "version": "latest" + } + }, + "networkProfile": { + "networkApiVersion": "2020-11-01", + "networkInterfaceConfigurations": [ + { + "name": "nicConfig", + "properties": { + "primary": true, + "ipConfigurations": [ + { + "name": "antmedia-cluster-vnet-nic01-defaultIpConfiguration", + "properties": { + "privateIPAddressVersion": "IPv4", + "subnet": { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]" + }, + "applicationGatewayBackendAddressPools": [ + { + "id": "[resourceId('Microsoft.Network/applicationGateways/backendAddressPools', variables('applicationGateWayName'), 'OriginBackendPool')]" + } + ], + "primary": true, + "publicIPAddressConfiguration": { + "name": "publicIp-antmedia-cluster-vnet-nic01", + "properties": { + "idleTimeoutInMinutes": 15, + "ipTags": [], + "publicIPAddressVersion": "IPv4" + } + } + } + } + ], + "networkSecurityGroup": { + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]" + } + } + } + ] + } + } + } + }, + { + "type": "Microsoft.Compute/virtualMachineScaleSets", + "apiVersion": "2023-03-01", + "name": "antmedia-edge", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]", + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]", + "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]" + + ], + "sku": { + "name": "[parameters('EdgeInstanceType')]", + "tier": "Standard", + "capacity": "[parameters('EdgeInstanceCapacity')]" + }, + "plan": { + "name": "enterprise_edition", + "product": "ant_media_server_enterprise", + "publisher": "antmedia" + }, + "properties": { + "platformFaultDomainCount": 1, + "singlePlacementGroup": false, + "orchestrationMode": "Flexible", + "virtualMachineProfile": { + "osProfile": { + "computerNamePrefix": "antmedia-", + "adminUsername": "[parameters('InstanceUsername')]", + "adminPassword": "[parameters('InstancePassword')]", + "linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), null(), variables('linuxConfiguration'))]", + "customData": "[base64('#!/bin/bash\nsudo sed -i \"/org.apache.catalina.valves.RemoteIpValve/d\" /usr/local/antmedia/conf/jee-container.xml\n/usr/local/antmedia/change_server_mode.sh cluster 10.0.1.99')]" + }, + "storageProfile": { + "osDisk": { + "createOption": "FromImage", + "managedDisk": { + "storageAccountType": "Premium_LRS" + } + }, + "imageReference": { + "publisher": "antmedia", + "offer": "ant_media_server_enterprise", + "sku": "enterprise_edition", + "version": "latest" + } + }, + "networkProfile": { + "networkApiVersion": "2020-11-01", + "networkInterfaceConfigurations": [ + { + "name": "nicConfig", + "properties": { + "primary": true, + "ipConfigurations": [ + { + "name": "antmedia-cluster-vnet-nic01-defaultIpConfiguration", + "properties": { + "privateIPAddressVersion": "IPv4", + "subnet": { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]" + }, + "applicationGatewayBackendAddressPools": [ + { + "id": "[resourceId('Microsoft.Network/applicationGateways/backendAddressPools', variables('applicationGateWayName'), 'EdgeBackendPool')]" + } + ], + "primary": true, + "publicIPAddressConfiguration": { + "name": "publicIp-antmedia-cluster-vnet-nic01", + "properties": { + "idleTimeoutInMinutes": 15, + "ipTags": [], + "publicIPAddressVersion": "IPv4" + } + } + } + } + ], + "networkSecurityGroup": { + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]" + } + } + } + ] + } + } + } + } + ] +} From 3338b277f0e1031066f8d56374d386ffd146cbbc Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Wed, 27 Mar 2024 01:19:55 +0300 Subject: [PATCH 02/10] Update depency issues --- .../antmedia-azure-autoscale.yaml | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml index e846b4f5..bc2d9520 100644 --- a/azure-arm-template/antmedia-azure-autoscale.yaml +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -508,8 +508,8 @@ "name": "antmedia-mongodb", "location": "[resourceGroup().location]", "dependsOn": [ - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]", - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]" + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworks_antmedia_cluster_vnet_name'))]", + "[resourceId('Microsoft.Network/networkSecurityGroups', 'MongoDB-Security-Group')]" ], "properties": { "hardwareProfile": { @@ -552,7 +552,9 @@ "name": "antmedia-mongodb-NIC", "location": "[resourceGroup().location]", "dependsOn": [ - "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworks_antmedia_cluster_vnet_name'))]" + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworks_antmedia_cluster_vnet_name'))]", + "[resourceId('Microsoft.Network/networkSecurityGroups', 'MongoDB-Security-Group')]" + ], "properties": { "ipConfigurations": [ @@ -581,9 +583,9 @@ "name": "antmedia-origin", "location": "[resourceGroup().location]", "dependsOn": [ - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]", - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]", - "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]" + "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]", + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworks_antmedia_cluster_vnet_name'))]", + "[resourceId('Microsoft.Network/applicationGateways/', variables('applicationGateWayName'))]" ], "sku": { @@ -670,9 +672,10 @@ "name": "antmedia-edge", "location": "[resourceGroup().location]", "dependsOn": [ - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'origin')]", - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'edge')]", - "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]" + "[resourceId('Microsoft.Network/networkSecurityGroups', 'AMSScaleSet-Security-Group')]", + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworks_antmedia_cluster_vnet_name'))]", + "[resourceId('Microsoft.Network/applicationGateways/', variables('applicationGateWayName'))]" + ], "sku": { From 069b321d37dff0389033621f05edb7e4e26ec1df Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Wed, 27 Mar 2024 16:26:34 +0300 Subject: [PATCH 03/10] Add Autoscale Policy --- .../antmedia-azure-autoscale.yaml | 97 ++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-) diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml index bc2d9520..79cdaef7 100644 --- a/azure-arm-template/antmedia-azure-autoscale.yaml +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -509,7 +509,8 @@ "location": "[resourceGroup().location]", "dependsOn": [ "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworks_antmedia_cluster_vnet_name'))]", - "[resourceId('Microsoft.Network/networkSecurityGroups', 'MongoDB-Security-Group')]" + "[resourceId('Microsoft.Network/networkSecurityGroups', 'MongoDB-Security-Group')]", + "[resourceId('Microsoft.Network/networkInterfaces', 'antmedia-mongodb-NIC')]" ], "properties": { "hardwareProfile": { @@ -666,7 +667,54 @@ } } }, - { + + { + "type": "Microsoft.Insights/autoscaleSettings", + "apiVersion": "2022-10-01", + "name": "AMSScaleSetAutoscaleSettings-Origin", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'antmedia-origin')]" + ], + "properties": { + "name": "AMSScaleSetAutoscaleSettings-Origin", + "targetResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'antmedia-origin')]", + "enabled": true, + "profiles": [ + { + "name": "DefaultProfile", + "capacity": { + "minimum": "1", + "maximum": "10", + "default": "1" + }, + "rules": [ + { + "metricTrigger": { + "metricName": "Percentage CPU", + "metricNamespace": "", + "metricResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'antmedia-origin')]", + "timeGrain": "PT1M", + "statistic": "Average", + "timeWindow": "PT5M", + "timeAggregation": "Average", + "operator": "GreaterThan", + "threshold": 60 + }, + "scaleAction": { + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + "cooldown": "PT5M" + } + } + ] + } + ] + } + }, + + { "type": "Microsoft.Compute/virtualMachineScaleSets", "apiVersion": "2023-03-01", "name": "antmedia-edge", @@ -755,6 +803,51 @@ } } } + }, + { + "type": "Microsoft.Insights/autoscaleSettings", + "apiVersion": "2022-10-01", + "name": "AMSScaleSetAutoscaleSettings-Edge", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'antmedia-edge')]" + ], + "properties": { + "name": "AMSScaleSetAutoscaleSettings-Edge", + "targetResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'antmedia-edge')]", + "enabled": true, + "profiles": [ + { + "name": "DefaultProfile", + "capacity": { + "minimum": "1", + "maximum": "10", + "default": "1" + }, + "rules": [ + { + "metricTrigger": { + "metricName": "Percentage CPU", + "metricNamespace": "", + "metricResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'antmedia-edge')]", + "timeGrain": "PT1M", + "statistic": "Average", + "timeWindow": "PT5M", + "timeAggregation": "Average", + "operator": "GreaterThan", + "threshold": 60 + }, + "scaleAction": { + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + "cooldown": "PT5M" + } + } + ] + } + ] + } } ] } From c9ee03d4db59ad3ebd77f9bc6df8909e94004303 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Wed, 27 Mar 2024 17:06:02 +0300 Subject: [PATCH 04/10] Fix AutoScale policy size --- azure-arm-template/antmedia-azure-autoscale.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml index 79cdaef7..cde85dc3 100644 --- a/azure-arm-template/antmedia-azure-autoscale.yaml +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -684,9 +684,9 @@ { "name": "DefaultProfile", "capacity": { - "minimum": "1", + "minimum": "[parameters('EdgeInstanceCapacity')]", "maximum": "10", - "default": "1" + "default": "[parameters('EdgeInstanceCapacity')]" }, "rules": [ { @@ -820,9 +820,9 @@ { "name": "DefaultProfile", "capacity": { - "minimum": "1", + "minimum": "[parameters('EdgeInstanceCapacity')]", "maximum": "10", - "default": "1" + "default": "[parameters('EdgeInstanceCapacity')]" }, "rules": [ { From 1837367ef776a06bba6cf2bae84b49ce5dbec952 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Wed, 27 Mar 2024 19:09:04 +0300 Subject: [PATCH 05/10] Add changeable CPU threshould --- azure-arm-template/antmedia-azure-autoscale.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml index cde85dc3..87a82f13 100644 --- a/azure-arm-template/antmedia-azure-autoscale.yaml +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -38,6 +38,13 @@ "description": "Type of Edge VMs in the VM Scale Set." } }, + "CPUPolicyTargetValue": { + "type": "int", + "defaultValue": 60, + "metadata": { + "description": "This parameter for creates new Instances when CPU load exceed to %60." + } + }, "MongoDBInstanceType": { "defaultValue": "Standard_D2s_v3", "type": "String", @@ -699,7 +706,7 @@ "timeWindow": "PT5M", "timeAggregation": "Average", "operator": "GreaterThan", - "threshold": 60 + "threshold": "[parameters('CPUPolicyTargetValue')]" }, "scaleAction": { "direction": "Increase", From 7839efa478682456c1103270202bb52a0bf952f5 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 1 Apr 2024 13:42:49 +0300 Subject: [PATCH 06/10] Update antmedia-azure-autoscale.yaml From 4fee1e750c8d41ba459380ffc298aa22ee147d13 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 1 Apr 2024 16:52:25 +0300 Subject: [PATCH 07/10] Add Inbound RTMP Port --- azure-arm-template/antmedia-azure-autoscale.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml index 87a82f13..34f7ead4 100644 --- a/azure-arm-template/antmedia-azure-autoscale.yaml +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -244,11 +244,11 @@ { "name": "cluster_rule2", "properties": { - "description": "Locks inbound down to Cluster default port 5000.", + "description": "Locks inbound down to Cluster default port 1935.", "protocol": "Tcp", "sourcePortRange": "*", - "destinationPortRange": "5000", - "sourceAddressPrefix": "10.0.0.0/16", + "destinationPortRange": "1935", + "sourceAddressPrefix": "0.0.0.0/0", "destinationAddressPrefix": "*", "access": "Allow", "priority": 102, From 8883be711c5f3d50a706dad52a6a685a27ed0e2c Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 1 Apr 2024 17:01:16 +0300 Subject: [PATCH 08/10] Update dependsOn for application gateway --- azure-arm-template/antmedia-azure-autoscale.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml index 34f7ead4..d29bdb3e 100644 --- a/azure-arm-template/antmedia-azure-autoscale.yaml +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -506,7 +506,8 @@ }, "dependsOn": [ "[resourceId('Microsoft.Network/publicIPAddresses', variables('appGwPublicIPAddressName'))]", - "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'app-gw')]" + "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworks_antmedia_cluster_vnet_name'), 'app-gw')]", + "[resourceId('Microsoft.Compute/virtualMachines', 'antmedia-mongodb')]" ] }, { From 72e2228045621179ac54165076d990704c388b39 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 1 Apr 2024 17:25:00 +0300 Subject: [PATCH 09/10] Update default instance types --- azure-arm-template/antmedia-azure-autoscale.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-arm-template/antmedia-azure-autoscale.yaml b/azure-arm-template/antmedia-azure-autoscale.yaml index d29bdb3e..6319e36a 100644 --- a/azure-arm-template/antmedia-azure-autoscale.yaml +++ b/azure-arm-template/antmedia-azure-autoscale.yaml @@ -17,7 +17,7 @@ }, "OriginInstanceType": { "type": "string", - "defaultValue": "Standard_D2s_v3", + "defaultValue": "Standard_F2s_v2", "metadata": { "description": "Size of Origin VMs in the VM Scale Set." } @@ -33,7 +33,7 @@ }, "EdgeInstanceType": { "type": "string", - "defaultValue": "Standard_D2s_v3", + "defaultValue": "Standard_F4s_v2", "metadata": { "description": "Type of Edge VMs in the VM Scale Set." } From abff539f383becec8f3ba8d82f5717af8b61ae94 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 1 Apr 2024 20:38:59 +0300 Subject: [PATCH 10/10] Add debug parameter --- .github/workflows/install-latest-to-ubuntu-22-04.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/install-latest-to-ubuntu-22-04.yml b/.github/workflows/install-latest-to-ubuntu-22-04.yml index 665d6780..6709c9c4 100644 --- a/.github/workflows/install-latest-to-ubuntu-22-04.yml +++ b/.github/workflows/install-latest-to-ubuntu-22-04.yml @@ -42,7 +42,7 @@ jobs: uses: actions/checkout@v3 - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." #Get latest version - - run: ./install_ant-media-server.sh -l"${{ secrets.ENTERPRISE_LICENSE }}" + - run: bash -x ./install_ant-media-server.sh -l"${{ secrets.ENTERPRISE_LICENSE }}" - run: sleep 30 - run: cat /usr/local/antmedia/log/ant-media-server.log - run: |