/

9. Configure Terraform Server


Install Red5 Pro Terraform Software on the Instance:

  1. Copy the terraform-service.zip file up to your server.
  2. SSH into the server, then run apt-get update.
  3. Install Java 8 and NTP (to ensure that the terraform server is in sync with your stream manager(s). Run: apt-get install -y default-jre unzip ntp
  4. Create a red5service directory in /usr/local (mkdir /usr/local/red5service)
  5. Unzip terraform-service.zip, and copy the following files to /usr/local/red5service
  6. application.properties
  7. cloud_controller_do.tf
  8. red5terra.sh
  9. terraform
  10. terraform-service-*.jar
  11. variables_do.tf
  12. Make red5terra.sh and terraform executable (chmod +x red5terra.sh terraform)
  13. Copy red5proterraform.service to /lib/systemd/system/
  14. Modify service properties, chmod 644 /lib/systemd/system/red5proterraform.service, then reload the daemon: systemctl daemon-reload, and enable the service systemctl enable red5proterraform.service

Update application.properties

Modify the following values in the application.properties file:

  • server.port - the port you will be running this service on (default = 8083)
  • api.accessToken - the token to use for making API calls to this service (to be used in the stream manager configuration)
  • terra.operationTimeoutMilliseconds - default timeout is set to 3 minutes (180000 milliseconds). Make this value higher if you will be initiating more than 20 nodes concurrently
  • terra.token - the Digital Ocean API token created above
  • terra.sshkey - the SSH key created above
  • terra.parallelism - the default, 10, should work well. If you are creating very large groups, you can set this to 30, but we don't recommend going much higher
  • config.dbHost -- the DB Endpoint URL of your PostgreSQL server instance
  • config.dbPort -- leave this as 25060, the default PostgreSQL port on DO
  • config.dbUser -- Database Master Username
  • config.dbPass -- Database Master Password

sample application.properties file:

#Server port configurations
server.port=8083

#Log level
logging.pattern.console=%d{yyyy-MM-dd} | %d{HH:mm:ss.SSS} | %5p | %-40.40logger{40} | %m%n
logging.level.com.red5pro.services.terraform.client.TerraformService=INFO

#Rest API token
api.accessToken=Kyj9aqLtLi6T

#Terraform configurations
terra.location=/usr/local/red5service
#set to 180000 for small groups; higher for larger groups
terra.operationTimeoutMilliseconds=180000
terra.token=912258d5db5d13a8e3xxxxxxxxxxxfdba334d4d13xxxxxxxxx85924d
terra.sshkey=id_autoscale
terra.parallelism=10

#DataBase configurations
config.dbHost=qa-terraform-db01-do-user-1234567-0.a.db.ondigitalocean.com
config.dbPort=25060
config.dbUser=doadmin
config.dbPass=ledtdjk9123niud5h
config.dbDriver=org.postgresql.Driver
config.dbName=cluster

Test terraform service

  1. To start the service manually, run: ./usr/local/red5service/red5terra.sh start
  2. Create GET call to {host}:8083/terraform/test?accessToken={api.accessToken} - response should be: Red5Pro Terraform Service is working

You can run the service directly via ./usr/local/red5service/red5terra.sh start (./usr/local/red5service/red5terra.sh stop to stop), or sudo systemctl start red5proterraform