Scripts and Config for deploying load balanced Coturn servers in Azure
Very much a work in progress.
Rough Steps:
-
Create and push docker images for turnserver, turn server loadbalancer, and turnadmin
-
Deploy (arm template) Azure PostgreSQL instance
- Create resource group for deployment
az group create --location 'Central US' --name 'azturntst-psql-rg'
- Deploy:
az group deployment create --name 'psql' --template-file ./psql/template.json --parameters '@./psql/parameters.json' --parameters "{\"administratorLogin\": {\"value\": \"matthew\"}, \"administratorLoginPassword\":{\"value\": \"GoodPasswordMaybe?\"}, \"serverName\": {\"value\": \"azturntstpsqlsrv\"}}" --resource-group "azturntst-psql-rg"
- Create resource group for deployment
-
Create database in above instance that will be used for TURN
-
Get connection string:
PSQL_ADMIN_CS=``./dbsetup/get_psql_connectionstring.sh azturntstpsqlsrv matthew "GoodPasswordMaybe?"`
-
Add IP to Firewall rule list for DB (or run in azure?)
-
Create database:
./dbsetup/create_turn_db.sh $PSQL_ADMIN_CS coturndb
-
-
Apply the coturn schema to the above database
-
Get connection string for new database:
PSQL_ADMIN_TDB_CS=``./dbsetup/get_psql_connectionstring.sh azturntstpsqlsrv matthew "GoodPasswordMaybe?" coturndb`
-
Copy turnserver schema:
curl https://raw.githubusercontent.com/coturn/coturn/master/turndb/schema.sql > schema.sql
-
Apply schema:
./dbsetup/apply_schema_to_turn_db.sh $PSQL_ADMIN_TDB_CS ./schema.sql
-
-
Create a role that can access the above database and related tables
./dbsetup/add_dbuser.sh $PSQL_ADMIN_TDB_CS coturn 'AnotherGoodPassword?' coturndb
-
Using the 'admin' container image create users for clients that will use the relay (requires PSQL connection string)
-
Create psql connection string for new user:
PSQL_COTURN_CS=``./dbsetup/get_psql_connectionstring.sh azturntstpsqlsrv coturn "AnotherGoodPassword?" coturndb`
-
Add user:
./dbsetup/add_turnuser.sh $PSQL_COTURN_CS user1 AGreatPassword azturntst.org
-
-
Deploy (arm template) N instances of TURN relay server (requires PSQL connection string and default realm)
- Create Resource group:
az group create --name "azturntst-rly-rg" --location "Central US"
- Edit parameters as desired, namely set the following:
instanceCount
- The number of turn servers that will be setupvirtualMachineNamePrefix
- The prefix used for various resources created (vm names, vnet, nsg, etc..)adminPublicKey
- The ssh public key that will be used to login to the machines if needed (Default user isturnroot
)diagnosticsStorageAccountName
- Storage account that turn VMS will log diagnostics topostgreSqlConnectionString
- Should be the same as the PSQL_COTURN_CS value abovedefaultTurnRealm
- Ideally the same as the one configured for the users you added in the above step (e.g. azturntst.org)turnImage
- The container image you created that runs the relay. (image created from 3dsrelay/)
- Deploy the template:
az group deployment create --resource-group "azturntst-rly-rg" --template-file 3dsrelay_arm\template.json --parameters "@3dsrelay_arm\parameters.json" --name "azturntstrly"
- Create Resource group:
-
Deploy (arm template) TURN servers for load balancing (requires the external IP for each of the TURN server instances created in the previous step)
- Get the ip addresses from the previous step:
az network public-ip list -g azturntst-rly-rg
- Create resource group for deployment:
az group create --name azturntst-rlylb-rg --location "Central US"
- Update parameters as desired, namely set the following:
vmssName
- Unique name that will be used for various resourcesinstanceCount
- The number of servers that will be behind the Network load balancersadminPublicKey
- The ssh public key that will be used to login to the machines (Default user isturnroot
)relayIPs
- A string containing space deliminated ip:port pairs for the relay servers (e.g. "24.55.76.33:3478 23.33.240.44:3478 36.34.243.55:3478")relayImage
- The docker image that will be used (image created from 3dsrelaylb/)
- Deploy the template:
az group deployment create --resource-group "azturntst-rlylb-rg" --template-file 3dsrelaylb_arm\template.json --parameters @3dsrelaylb_arm\parameters.json --name azturntstrlylb
- Get the public ip for it to use for client/server config:
az network public-ip list -g azturntst-rlylb-rg
- Get the ip addresses from the previous step:
-
Done?
Obviously still lots of work to automate this E2E and at some point there should be another amangement interface instead of a bunch of scripts talking directly to PSQL.