How do I set up dynamic port mapping for Amazon ECS?

0

Short description
The Classic Load Balancer doesn't allow you to run multiple copies of a task on the same instance. Instead, with the Classic Load Balancer, you must statically map port numbers on a container instance. However, an Application Load Balancer uses dynamic port mapping, so you can run multiple tasks from a single service on the same container instance.

Resolution
To set up dynamic port mapping, follow these steps:

Create an Application Load Balancer and a target group.
Important: To route health check traffic correctly when you create a target group, expand Advanced health check settings. For Port, select traffic port.
Open the Amazon ECS console, and then set the host port to 0 for the task definition that you're creating or updating. Be sure to set the container port mappings for your application.
Important: The host and awsvpc network modes do not support dynamic host port mapping.
Add a rule to allow inbound traffic from your load balancer to your container instances. The security group and network access control list (network ACL) must allow traffic from the load balancer to the instances over the ephemeral port range.
Note: For more information about ephemeral port ranges, see PortMapping.
Open the Amazon ECS console, and then configure your service to use the Application Load Balancer that you created.
Important: You can add a load balancer only during the creation of the service. After service creation, you can't change the target group's Amazon Resource Name (ARN), container name, or the container port specified in the service definition. You can't add, remove, or change the load balancer configuration of an existing service. If you update the service task definition, then the container name and container port specified at service creation must remain in the task definition. For more information, see Service load balancing.
Open the Amazon Elastic Compute Cloud (Amazon EC2) console, and then choose Target Groups from the navigation pane. Choose the hyperlinked name for your target group. From the Targets tab, you can see which port is used for the task in the service that you created.

profile picture
질문됨 3년 전1346회 조회
3개 답변
0

Short description
The Classic Load Balancer doesn't allow you to run multiple copies of a task on the same instance. Instead, with the Classic Load Balancer, you must statically map port numbers on a container instance. However, an Application Load Balancer uses dynamic port mapping, so you can run multiple tasks from a single service on the same container instance.

Resolution
To set up dynamic port mapping, follow these steps:

Create an Application Load Balancer and a target group.
Important: To route health check traffic correctly when you create a target group, expand Advanced health check settings. For Port, select traffic port.
Open the Amazon ECS console, and then set the host port to 0 for the task definition that you're creating or updating. Be sure to set the container port mappings for your application.
Important: The host and awsvpc network modes do not support dynamic host port mapping.
Add a rule to allow inbound traffic from your load balancer to your container instances. The security group and network access control list (network ACL) must allow traffic from the load balancer to the instances over the ephemeral port range.
Note: For more information about ephemeral port ranges, see PortMapping.
Open the Amazon ECS console, and then configure your service to use the Application Load Balancer that you created.
Important: You can add a load balancer only during the creation of the service. After service creation, you can't change the target group's Amazon Resource Name (ARN), container name, or the container port specified in the service definition. You can't add, remove, or change the load balancer configuration of an existing service. If you update the service task definition, then the container name and container port specified at service creation must remain in the task definition. For more information, see Service load balancing.
Open the Amazon Elastic Compute Cloud (Amazon EC2) console, and then choose Target Groups from the navigation pane. Choose the hyperlinked name for your target group. From the Targets tab, you can see which port is used for the task in the service that you created.

profile picture
답변함 3년 전
0

reopen

profile picture
답변함 3년 전
0

"helpful"

profile picture
답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠