Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exposing to public more than 1 port with AWS ECS service and Elastic LoadBalancer

I have service that exposes multiple ports and it worked fine with kubernetes but now we move it to AWS ECS. It seems I can only expose ports via Load Balancer and I am limited to 1 port per service/tasks even when docker defines multiple ports I have to choose one port

enter image description here

Add to load balancer button allows to add one port. Once added there is no button to add second port.

Is there any nicer workarround than making second proxy service to expose second port?

UPDATE: I use fargate based service.

like image 320
user3130782 Avatar asked Aug 29 '19 18:08

user3130782


People also ask

How do I use one AWS Loadbalancer for multiple services?

How do I even load balance in this case? You can Register ECS service with ALB so Load balancer will route traffic to the container service and it will not look for an EC2 instance, so you can run a replica of service on many EC2 instances. and you can register multiple ECS service with one load balancer.

Do I need a load balancer with ECS?

We recommend that you use Application Load Balancers for your Amazon ECS services so that you can take advantage of these latest features, unless your service requires a feature that is only available with Network Load Balancers or Classic Load Balancers.

How many requests can a load balancer handle AWS?

Network Load Balancer currently supports 200 targets per Availability Zone. For example, if you are in two AZs, you can have up to 400 targets registered with Network Load Balancer. If cross-zone load balancing is on, then the maximum targets reduce from 200 per AZ to 200 per load balancer.

Can we attach multiple target groups to load balancer?

For services that use an Application Load Balancer or Network Load Balancer, you cannot attach more than five target groups to a service.


1 Answers

You don't need any workaround, AWS ECS now supports multiple target groups within the same ECS service. This will be helpful for the use-cases where you wanted to expose multiple ports of the containers.

Currently, if you want to create a service specifying multiple target groups, you must create the service using the Amazon ECS API, SDK, AWS CLI, or an AWS CloudFormation template. After the service is created, you can view the service and the target groups registered to it with the AWS Management Console.

For example, A Jenkins container might expose port 8080 for the Jenkins web interface and port 50000 for the API.

Ref:

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/register-multiple-targetgroups.html

https://aws.amazon.com/about-aws/whats-new/2019/07/amazon-ecs-services-now-support-multiple-load-balancer-target-groups/

like image 72
mohit Avatar answered Oct 30 '22 13:10

mohit