简体   繁体   中英

AWS Fargate: How to deploy a service fargate task with a network load balancer

Background

  • Current State : I currently have a nlb that routes to an nginx server running on an ec2 instance.

Goal

  • I am trying to replace the nginx ec2 instance with a fargate service that runs nginx.
  • I would like to keep the current nlb and set the fargate cluster as the target group for the existing nlb.

Problem

  • according to aws documentation, aws ecs fargate cluster service supports loadbalancing with nlb or alb: https://docs.aws.amazon.com/AmazonECS/latest/userguide/service-load-balancing.html
  • when I try to deploy the nginx task, in the load balancing section, there is only an option to select an existing alb or create a new alb.
  • I tried changing the task protocol to TCP and UDP--regardless of the protocol, when I try to deploy the task as a service, the only load balancer option is still application load balancer.

Question

  • How do I load balance to a fargate cluster service task using an nlb? Am I missing a specific setting somewhere?
  • If you cannot set the fargate cluster as a target group for an nlb directly, would it be reasonable to route traffic from an nlb to an alb and then set the alb target group as a fargate cluster?

You can absolutely use an NLB with an ECS Fargate service. I've done this before many times. My guess is you are simply encountering a bug in the AWS web UI. I've always used Terraform to deploy this sort of thing. I just checked in the ECS web UI, and on the 2nd step of creating a new ECS service I get the option of using a Network Load Balancer:

在此处输入图像描述

If your view doesn't look like that, try switching from the "New ECS Experience" in the UI which is still fairly beta and missing a lot of features.


I just went back and checked, and in the new ECS UI they are currently missing the option to select an NLB, so you have to continue using the old version of the UI for now until they fix that. I suggest continuing to use the old UI until they phase it out, because the new ECS UI is still missing a lot of features.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM