0

我通过创建具有 1 个实例的集群并在该实例上运行容器任务,在 1 个 EC2 实例上部署了一个 http 侦听器容器化应用程序。

我正在使用 Auto Scaling EC2 实例功能,最小实例为 1,最大实例为 4。

我面临的问题是。

  1. 一旦由于更多的负载/ CPU 利用率而创建了新的 EC2 实例 - 部署在第一个实例上的容器不会在这些新实例上复制。

  2. 我想在这些 EC2 实例添加(或终止)时添加负载均衡器。由于实例需要已经注册到目标组 - 我将无法添加新实例,因为它们尚未创建。

非常感谢您对此的任何帮助。

4

1 回答 1

1

您对 ALB + ASG 作为一项技术的工作方式存在一些误解。

自动缩放组与目标组相关联。因此,与 ALB 目标组关联的 ASG 中的任何实例事实上都将成为 ALB 的可行目标 - 只要该实例是健康的。

I want to add load balancer in front of these EC2 instances as and
when they gets added (or terminated). As the instances needs to be
already registered to the target group - i will not be able to add
the new instances as they are not yet created.

将实例添加到 ASG,并且 ASG 由目标组定位。创建 ALB,为 ALB 创建目标组,创建 ASG 并将其分配给目标组。

对于你的第一个问题:

Once new EC2 instances are created due to more load/ CPU utilization -
the container which were deployed on first instance is not replicated
on these new instances.

ASG 不会克隆现有实例;它们从与原始实例相同的启动配置中生成一个新实例。您在原始实例上所做的任何手动设置都不会出现在新实例上。你有两种方法来解决这个问题:\

  1. 创建您的第一个实例的 AMI,并更改 ASG 的启动配置以使用此新 AMI
  2. 利用 Userdata 在实例启动时自动配置您的容器化服务。
于 2018-04-26T14:34:26.667 回答