简体   繁体   中英

Health check on container port and host port in ECS + ALB

I have a problem with my deployment in ECS.

I try to deploy 4 instances of 2 docker images on 2 EC2 instances with an ALB in front.

So in my tasks definitions, I use the dynamic port mapping (2 Nginx on container port 80).

This creates a trouble in the Health check of my target group. In fact, for each instance, I have a health check on the dynamics port (that is ok) and on the container port (80).

So the dynamic port says, it's ok. And the container port, logically says unhealthy ... (Like in my screenshot) 在此处输入图片说明

So can you help me ton find why I have that type of error (this error make my server terminated each 5 minutes....)

Thanks in advance for your help :D

So to me it looks like you aren't completely using dynamic port mapping. For dynamic port mapping you have

Client -> ALB (port 80) -> EC2 host (dynamic port) -> container (dynamic port) -> nginx (port 80)

None of your healthchecks should be hitting port 80 since the only thing that uses port 80 is external connection into your application and nginx (but it is mapped to a different port). For ALB healthchecks all you really need is a path to hit and the port will default to the port that it connects on.

See the host port mapping in this doc: http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html

ALB Health Check Docs: http://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html

I found the solution with the AWS support.

So there are two problems here:

  1. To disable the health which kill the EC2 instance, go to the auto scaling group and switch health check to "EC2" type

  2. To remove the health check on port 80, go to the auto scaling group, and under "Target groups" section, removes the target groups managed by ECS

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