使用 Application Load Balancer 时无法将简单 HTTP 服务器部署到 ElasticBeanstalk

发布于 2025-01-11 14:09:37 字数 1373 浏览 0 评论 0原文

我无法将最简单的 docker-compose 文件部署到配置了应用程序负载均衡器以实现高可用性的 ElasticBeanstalk 环境。

这是 docker 文件:

version: "3.9"

services:
  demo:
    image: nginxdemos/hello
    ports:
      - "80:80"
    restart: always

这是 ALB 配置: ALB 配置

EB 事件链:

  1. 创建 CloudWatch 警报和日志组
  2. 创建安全组
    1. 对于负载均衡器
      1. 允许端口 80/443 上的来自互联网的传入流量到达我的两个侦听器
    2. 对于 EC2 机器
      1. 允许传入流量从创建的第一个安全组流向process端口
  3. 自动扩展组
  4. 创建应用程序负载均衡器
  5. 创建EC2实例

大约。创建 EC2 实例 (#5) 10 分钟后,我收到以下日志:

环境健康状况已从“待处理”转变为“严重”。 ELB 进程并非在所有实例上都运行正常。正在进行初始化(运行 12 分钟)。没有实例正在发送数据。 50.0% 的 ELB 请求因 HTTP 5xx 失败。请求率(2.0 个请求/分钟)不足以确定应用程序运行状况(6 分钟前)。 ELB 运行状况出现故障或不适用于所有实例。

查看目标组,它指示0 个健康实例(基于默认的运行状况检查)

当通过 SSH 连接实例时,我看到 docker 服务甚至没有启动,我的应用程序也没有运行。这就解释了为什么该实例不健康

然而,我应该做些什么不同的事情呢?根据我的理解,对我来说,它看起来像是由 ElasticBealstalk 启动的流程中的错误,因为该流程在启动我的应用程序之前正在等待实例健康 (否则,为什么在创建 EC2 实例后 10 分钟内应用程序还没有启动?)

这看起来不像是应用程序问题,因为 docker 服务甚至没有启动。

感谢您的帮助。

I'm unable to deploy the simplest docker-compose file to an ElasticBeanstalk environment configured with Application Load Balancer for high-availability.

This is the docker file:

version: "3.9"

services:
  demo:
    image: nginxdemos/hello
    ports:
      - "80:80"
    restart: always

This is the ALB configuration:
ALB configuration

EB Chain of events:

  1. Creating CloudWatch alarms and log groups
  2. Creating security groups
    1. For the load balancer
      1. Allow incoming traffic from the internet to my two listerners on ports 80/443
    2. For the EC2 machines
      1. Allow incoming traffic to the process port from the first security group created
  3. Create auto scaling groups
  4. Create Application Load Balancer
  5. Create EC2 instance

Approx. 10 minutes after creating the EC2 instance (#5), I get the following log:

Environment health has transitioned from Pending to Severe. ELB processes are not healthy on all instances. Initialization in progress (running for 12 minutes). None of the instances are sending data. 50.0 % of the requests to the ELB are failing with HTTP 5xx. Insufficient request rate (2.0 requests/min) to determine application health (6 minutes ago). ELB health is failing or not available for all instances.

Looking at the Target Group, it is indicating 0 healthy instances (based on the default healthchecks)

When SSH'ing the instance, I see that the docker service is not even started, and my application is not running. So that explains why the instance is unhealthy.

However, what am I supposed to do differently? based on the understanding I have, to me it looks like a bug in the flow initiated by ElasticBealstalk, as the flow is waiting for the instances to be healthy before starting my application (otherwise, why the application wasn't started in the 10 minutes after the EC2 instance was created?)

It doesn't seem like an application issue, because the docker service was not even started.

Appreciate your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不再让梦枯萎 2025-01-18 14:09:37

我尝试使用您的 docker-compose.yml 和在 64 位 Amazon Linux 2/3.4.12 平台上运行的 Docker 来复制您的问题。为了进行测试,我创建了一个仅包含 docker-compose.yml 的 zip 文件。

一切按预期工作,没有发现任何问题。

我唯一可以建议的是仔细检查你的文件。此外,没有理由使用 443,因为您根本没有 https。

I tried to replicate your issue using your docker-compose.yml and Docker running on 64bit Amazon Linux 2/3.4.12 platform. For the test I created a zip file containing only the docker-compose.yml.

Everything works as expected and no issues were found.

The only thing I can suggest is to double check your files. Also there is no reason to use 443 as you don't have https at all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文