I have created a ECS cluster defining min capacity as 1 instance. It's running fine. I have a task definition with a simple js express app running fibonacci app (to simulate CPU usage for large fib numbers), as well as a container running nginx proxy.
I want to set up a ALB to route incoming traffic to tasks within the cluster (launched using TaskDef > Service).
I am following this article but he is not using ECS cluster with instances linked to it (but rather just straight EC2 instances it seems).
So when setting up the ALB > Listener TargetGroup, what do I need to select?
I saw somewhere (can't remember where) that it should be IP addresses, and then not to register any targets to the TargetGroup created (because ECS does this automatically?) Is that how it works?
When I select "IP addresses" I get the following screen - what should I enter for the IP address from subnet entry(ies)? use the private ones? I have no idea ... (although step is optional, perhaps I should just skip it?)
I would like to run only one task per instance (the task itself has 2 containers), and scale instances in and out based on CPU usage of the instance.
I saw somewhere (can't remember where) that it should be IP addresses, and then not to register any targets to the TargetGroup created (because ECS does this automatically?) Is that how it works?
Yes, that's how it works, although you may need to select instance
instead of ip
depending on the network mode of your ECS tasks. Per the documentation:
"For services with tasks using the awsvpc network mode, when you create a target group for your service, you must choose ip as the target type, not instance. This is because tasks that use the awsvpc network mode are associated with an elastic network interface, not an Amazon EC2 instance."
When I select "IP addresses" I get the following screen - what should I enter for the IP address from subnet entry(ies)? use the private ones? I have no idea ... (although step is optional, perhaps I should just skip it?)
Yes, you need to skip that step.
After creating the Application Load Balancer and empty Target Group, you will need to edit your ECS Service to be aware of the load balancer and target group. At that point the ECS service will automatically add ECS tasks to the target group as they are started, and remove them as they are stopped.
I highly recommend you read everything on this page of the documentation.