From 0cf6efdae962cab71272f113b6d5a8684c1178cb Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 12 Jul 2021 16:13:41 -0700 Subject: [PATCH] Remove ECS terraform from repo, updated README (#49) --- README.md | 18 +++-- deploy/aws-ecs/.gitignore | 2 - deploy/aws-ecs/config.tf | 72 ------------------ deploy/aws-ecs/ecs_cluster.tf | 26 ------- deploy/aws-ecs/ecs_task.tf | 46 ----------- deploy/aws-ecs/example.tfvars | 53 ------------- deploy/aws-ecs/iam.tf | 26 ------- deploy/aws-ecs/load_balancer.tf | 29 ------- deploy/aws-ecs/main.tf | 131 -------------------------------- deploy/aws-ecs/networking.tf | 111 --------------------------- deploy/aws-ecs/redis/README.md | 7 -- deploy/aws-ecs/redis/main.tf | 33 -------- deploy/aws-ecs/redis/redis.tf | 18 ----- 13 files changed, 10 insertions(+), 562 deletions(-) delete mode 100644 deploy/aws-ecs/.gitignore delete mode 100644 deploy/aws-ecs/config.tf delete mode 100644 deploy/aws-ecs/ecs_cluster.tf delete mode 100644 deploy/aws-ecs/ecs_task.tf delete mode 100644 deploy/aws-ecs/example.tfvars delete mode 100644 deploy/aws-ecs/iam.tf delete mode 100644 deploy/aws-ecs/load_balancer.tf delete mode 100644 deploy/aws-ecs/main.tf delete mode 100644 deploy/aws-ecs/networking.tf delete mode 100644 deploy/aws-ecs/redis/README.md delete mode 100644 deploy/aws-ecs/redis/main.tf delete mode 100644 deploy/aws-ecs/redis/redis.tf diff --git a/README.md b/README.md index e7098acf2..9f1319c78 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,8 @@ APIwLeah7g4fuLYDYAJeaKsSE: 8nTlwISkb-63DPP7OH4e.nw.J44JjicvZDiz8J59EoQ+ ### Starting the server -In development mode, LiveKit has no external dependencies. With the key file ready, you can start LiveKit with +In development mode, LiveKit has no external dependencies. You can start LiveKit by passing it the keys it should use in `LIVEKIT_KEYS`. +LiveKit could also use a [config file](config-sample.yaml) or config environment variable `LIVEKIT_CONFIG` ```shell LIVEKIT_KEYS=": " ./bin/livekit-server --dev @@ -107,15 +108,10 @@ docker run --rm \ --node-ip= ``` +When running with docker, `--node-ip` needs to be set to your machine's local IP address. + The `--dev` flag turns on log verbosity to make it easier for local debugging/development -### Sample client - -To test your server, you can use our [example web client](https://example.livekit.io/) -(built with our [React component](https://github.com/livekit/livekit-react)) - -Enter generated access token and you are connected to a room! - ### Creating a JWT token To create a join token for clients, livekit-server provides a convenient subcommand to create a **development** token. @@ -125,6 +121,12 @@ This token has an expiration of a month, which is useful for development & testi ./bin/livekit-server --key-file create-join-token --room "myroom" --identity "myidentity" ``` +### Sample client + +To test your server, you can use our [example web client](https://example.livekit.io/) +(built with our [React component](https://github.com/livekit/livekit-react)) + +Enter generated access token and you are connected to a room! ## Deploying for production diff --git a/deploy/aws-ecs/.gitignore b/deploy/aws-ecs/.gitignore deleted file mode 100644 index a82a34900..000000000 --- a/deploy/aws-ecs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.terraform* -terraform.tfstate* \ No newline at end of file diff --git a/deploy/aws-ecs/config.tf b/deploy/aws-ecs/config.tf deleted file mode 100644 index 13e92c8a2..000000000 --- a/deploy/aws-ecs/config.tf +++ /dev/null @@ -1,72 +0,0 @@ -locals { - livekit_config = { - port = var.http_port - rtc = { - port_range_start = var.udp_port_start - port_range_end = var.udp_port_end - tcp_port = var.rtc_tcp_port - udp_port = var.rtc_udp_port - use_external_ip = true - } - turn = { - enabled = var.turn_enabled - tcp_port = var.turn_tcp_port - udp_port = var.turn_udp_port - port_range_start = var.turn_port_start - port_range_end = var.turn_port_end - } - development = true - keys = var.api_keys - redis = { - address = var.redis_address - } - } - - // mapping contains only the main listening ports - // other UDP ports don't have to be mapped, due to using host-mode - port_mapping = [ - { - containerPort = var.http_port - protocol = "tcp" - }, - { - containerPort = var.turn_tcp_port - protocol = "tcp" - }, - { - containerPort = var.turn_udp_port - protocol = "udp" - }, - { - containerPort = var.rtc_udp_port - protocol = "udp" - }, - { - containerPort = var.rtc_tcp_port - protocol = "tcp" - } - ] - - task_config = [{ - name = "livekit" - image = "livekit/livekit-server:${var.livekit_version}" - cpu = 1024 - memory = 1024 - essential = true - environment = [ - { - name = "LIVEKIT_CONFIG" - value = yamlencode(local.livekit_config) - } - ] - logConfiguration = { - logDriver = "awslogs" - options = { - "awslogs-region" = var.region - "awslogs-group" = "livekit" - "awslogs-stream-prefix" = var.name - } - }, - portMappings = local.port_mapping - }] -} \ No newline at end of file diff --git a/deploy/aws-ecs/ecs_cluster.tf b/deploy/aws-ecs/ecs_cluster.tf deleted file mode 100644 index e48733dcc..000000000 --- a/deploy/aws-ecs/ecs_cluster.tf +++ /dev/null @@ -1,26 +0,0 @@ -data "aws_ami" "ecs_ami" { - most_recent = true - owners = ["amazon"] - - filter { - name = "name" - values = ["amzn-ami-*-amazon-ecs-optimized"] - } -} - -module "app_ecs_cluster" { - source = "trussworks/ecs-cluster/aws" - - name = "livekit" - environment = var.name - - image_id = data.aws_ami.ecs_ami.image_id - instance_type = var.instance_type - - vpc_id = var.vpc_id - subnet_ids = var.subnet_ids - security_group_ids = concat(var.security_groups, [aws_security_group.main.id]) - desired_capacity = var.nodes - max_size = var.max_nodes - min_size = var.min_nodes -} diff --git a/deploy/aws-ecs/ecs_task.tf b/deploy/aws-ecs/ecs_task.tf deleted file mode 100644 index f4b996f5e..000000000 --- a/deploy/aws-ecs/ecs_task.tf +++ /dev/null @@ -1,46 +0,0 @@ -resource "aws_ecs_task_definition" "livekit" { - family = "service" - container_definitions = jsonencode(local.task_config) - network_mode = "host" - execution_role_arn = aws_iam_role.ecs_role.arn -} - -resource "aws_ecs_service" "livekit" { - name = "livekit-${var.name}" - cluster = module.app_ecs_cluster.ecs_cluster_arn - task_definition = aws_ecs_task_definition.livekit.arn - desired_count = var.nodes - force_new_deployment = true - launch_type = "EC2" - - placement_constraints { - // one instance per node - type = "distinctInstance" - } - - ordered_placement_strategy { - type = "spread" - field = "instanceId" - } - - // load balancer for HTTP port - load_balancer { - target_group_arn = aws_lb_target_group.http.arn - container_name = "livekit" - container_port = var.http_port - } - - depends_on = [ - aws_lb_listener.http - ] - - // lifecycle { - // ignore_changes = [desired_count] - // } -} - -resource "aws_cloudwatch_log_group" "livekit" { - name = "livekit" - - retention_in_days = 7 -} diff --git a/deploy/aws-ecs/example.tfvars b/deploy/aws-ecs/example.tfvars deleted file mode 100644 index 4d7c766df..000000000 --- a/deploy/aws-ecs/example.tfvars +++ /dev/null @@ -1,53 +0,0 @@ -# name of the livekit cluster, resources will be called `livekit-${name}` -name = "demo" - -# type of instance to use -instance_type = "t3.small" - -# limits to the number of nodes to run -max_nodes = 2 - -# minimum number of nodes to run -min_nodes = 1 - -# initially use this number of nodes -nodes = 1 - -# VPC to create the cluster in -vpc_id = "" - -# List of subnet IDs to create the cluster in -subnet_ids = [] - -# region to use, must match AWS_REGION environment variable -region = "us-east-1" - -# additional security groups to attach the cluster to. -# include security group of the redis instance to allow access -security_groups = [ - "" -] - -# Livekit configuration - -# address and port to redis instance -redis_address = "" - -# list of API keys and secrets -api_keys = { - "key" = "secret" -} - -# UDP port range for WebRTC, uncomment to override -// udp_port_start = 9000 -// udp_port_end = 11000 - -# Use embedded TURN server, defaults true -// turn_enabled = true -// turn_tcp_port = 3478 -// turn_udp_port = 3479 - -# UDP port range for embedded TURN server -// turn_port_start = 11001 -// turn_port_end = 13000 - diff --git a/deploy/aws-ecs/iam.tf b/deploy/aws-ecs/iam.tf deleted file mode 100644 index c9fc5aaae..000000000 --- a/deploy/aws-ecs/iam.tf +++ /dev/null @@ -1,26 +0,0 @@ - -// role for ECS execution -resource "aws_iam_role" "ecs_role" { - name = "livekit-${var.name}-execution" - - assume_role_policy = < terraform apply` - -Enter a name for the cluster, as well as the subnet ids that Redis should be created in diff --git a/deploy/aws-ecs/redis/main.tf b/deploy/aws-ecs/redis/main.tf deleted file mode 100644 index 7ec52203c..000000000 --- a/deploy/aws-ecs/redis/main.tf +++ /dev/null @@ -1,33 +0,0 @@ -# -# The following variables need to be set: -# AWS_ACCESS_KEY_ID (or reads from ~/.aws/credentials) -# AWS_SECRET_ACCESS_KEY (or reads from ~/.aws/credentials) -# AWS_REGION -# -provider "aws" { -} - -# type of instance to deploy on -# see: https://aws.amazon.com/elasticache/pricing/ -variable "instance_type" { - type = string - default = "cache.t3.micro" -} - -# name of the cluster -variable "cluster_id" { - type = string -} - -# launch in the following subnet ids -variable "subnet_ids" { - type = list(string) -} - -variable "security_groups" { - type = list(string) -} - -output "address" { - value = "${aws_elasticache_cluster.main.cache_nodes[0].address}:${aws_elasticache_cluster.main.cache_nodes[0].port}" -} \ No newline at end of file diff --git a/deploy/aws-ecs/redis/redis.tf b/deploy/aws-ecs/redis/redis.tf deleted file mode 100644 index e090735b4..000000000 --- a/deploy/aws-ecs/redis/redis.tf +++ /dev/null @@ -1,18 +0,0 @@ -resource "aws_elasticache_cluster" "main" { - cluster_id = var.cluster_id - engine = "redis" - node_type = var.instance_type - num_cache_nodes = 1 - parameter_group_name = "default.redis6.x" - # strangely terraform requires you to change to a specific version when - # modifying the resource. - engine_version = "6.x" - subnet_group_name = aws_elasticache_subnet_group.main.name - security_group_ids = var.security_groups - port = 6379 -} - -resource "aws_elasticache_subnet_group" "main" { - name = var.cluster_id - subnet_ids = var.subnet_ids -}