AWS - ECS

Run Lumeo Gateways in AWS Elastic Container Service

Overview

Lumeo Gateways can be deployed in AWS Elastic Container Service using a EC2 Capacity provider.

Note: Fargate is not currently supported since it does not allow GPU-based tasks.

Within an ECS cluster, new Lumeo Gateways are created when spawning new Tasks or increasing the tasks within a Service definition. These Gateways will appear in the Lumeo console and are usable to deploy analytics.

Scaling down the number of Tasks will have those Gateways go offline in the Lumeo console.

ECS Configuration

Create ECS Cluster

Highlights:

  • Use a Amazon EC2 instances as the Infrastructure for your cluster, and create an EC2 Auto Scaling Group as a Capacity Provider for the ECS cluster
  • Setup the EC2 Auto Scaling Group to use g4 instances, ex: g4dn.xlarge, g4dn.2xlarge, etc. Ensure you have requested enough quota for these instances in your AWS account. This guide assumes we are using g4dn.xlarge instances.
  • Setup the instances to use atleast 100GB for the Root EBS volume size to accommodate Lumeo container images.

Create ECS Task Definition

Using JSON

This is the easiest way to create a task definition.

Select Create new task definition with JSON

Select Create new task definition with JSON

Note down the executionRoleArn and replace in the provided template below. Then replace the entire template here.

Note down the executionRoleArn and replace in the provided template below. Then replace the entire template here.

In the task definition JSON template is provided below, replace the following fields:

  • containerDefinitions.environment values for LUMEO_APP_ID and LUMEO_API_KEY
  • executionRoleArn replace with the one found in "Create new task definition from JSON"
  • memory replace with the actual amount of memory available on your instance.
{
    "family": "lumeo-gateway",
    "containerDefinitions": [
        {
            "name": "lumeo-gateway",
            "image": "docker.io/lumeo/gateway-nvidia-dgpu:latest",
            "cpu": 0,
            "portMappings": [
                {
                    "name": "lumeo-gateway-554-tcp",
                    "containerPort": 554,
                    "hostPort": 554,
                    "protocol": "tcp"
                },
                {
                    "containerPort": 554,
                    "hostPort": 554,
                    "protocol": "udp"
                }
            ],
            "essential": true,
            "environment": [
                {
                    "name": "CONTAINER_MODEL",
                    "value": "AWS ECS"
                },
                {
                    "name": "LUMEO_APP_ID",
                    "value": "<replace with your workspace id>"
                },
                {
                    "name": "LUMEO_API_KEY",
                    "value": "<replace with your API Key>"
                }
            ],
            "mountPoints": [
                {
                    "sourceVolume": "lumeo-gateway-storage",
                    "containerPath": "/var/lib/lumeo",
                    "readOnly": false
                }
            ],
            "volumesFrom": [],
            "startTimeout": 120,
            "logConfiguration": {
                "logDriver": "awslogs",
                "options": {
                    "awslogs-create-group": "true",
                    "awslogs-group": "/ecs/lumeo-gateway",
                    "awslogs-region": "us-east-1",
                    "awslogs-stream-prefix": "ecs"
                },
                "secretOptions": []
            },
            "resourceRequirements": [
                {
                    "value": "1",
                    "type": "GPU"
                }
            ]
        }
    ],
    "executionRoleArn": "<replace with your execution role arn>",
    "networkMode": "bridge",
    "volumes": [
        {
            "name": "lumeo-gateway-storage",
            "dockerVolumeConfiguration": {
                "scope": "task",
                "driver": "local"
            }
        }
    ],
    "requiresCompatibilities": [
        "EC2"
    ],
    "memory": "15360",
    "runtimePlatform": {
        "cpuArchitecture": "X86_64",
        "operatingSystemFamily": "LINUX"
    }
}

Using GUI

As an alternative to using JSON to create the task definition, you can create one using the GUI following the steps below.

Task Definition (1/4) : Select EC2 Instances, and ensure the Task Size Memory is set to the maximum available in your instance (ex. 15 GB)

Task Definition (1/4) : Select EC2 Instances, and ensure the Task Size Memory is set to the maximum available in your instance (ex. 15 GB)

Task Definition (2/4) : Add a container, specify the correct image URI, and port mappings. Ensure Resource allocation limits - GPU is set to 1. **Do not set CPU, Memory Hard / soft limits.**

Task Definition (2/4) : Add a container, specify the correct image URI, and port mappings. Ensure Resource allocation limits - GPU is set to 1. Do not set CPU, Memory Hard / soft limits.

Task Definition (3/4) : Set CONTAINER_MODEL, LUMEO_API_KEY and LUMEO_APP_ID environment variables. Enable Log collection.

Task Definition (3/4) : Set CONTAINER_MODEL, LUMEO_API_KEY and LUMEO_APP_ID environment variables. Enable Log collection.

Add a volume, type Docker volume. Set Driver to "local" (case matters). Create a mount point for that volume at `/var/lib/lumeo`

Add a volume, type Docker volume. Set Driver to "local" (case matters). Create a mount point for that volume at /var/lib/lumeo

Create ECS Service

Create a new Service in the cluster. Choose default Capacity provider strategy.

Create a new Service in the cluster. Choose default Capacity provider strategy.

Chose `lumeo-gateway` family for task definition, and set Desired tasks to the number of gateways you wish to launch.

Chose lumeo-gateway family for task definition, and set Desired tasks to the number of gateways you wish to launch.

After configuring the service, hit create, and wait for the Lumeo Gateways to show up in your Lumeo console. You can increase the number of gateways by increasing the number of tasks.

However, when you decrease the number of gateways by reducing the tasks, those gateways will go offline in the Lumeo Console, and the deployments will not automatically migrate.