为什么我的 ECS 服务无法向我的 ELB 注册可用的 EC2 实例? [英] Why can't my ECS service register available EC2 instances with my ELB?

查看:18
本文介绍了为什么我的 ECS 服务无法向我的 ELB 注册可用的 EC2 实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 EC2 启动配置来构建 ECS 优化的 AMI.我有一个 Auto Scaling 组,可确保我始终拥有至少两个可用实例.最后,我有了一个负载平衡器.

I've got an EC2 launch configuration that builds the ECS optimized AMI. I've got an auto scaling group that ensures that I've got at least two available instances at all times. Finally, I've got a load balancer.

我正在尝试创建一个 ECS 服务,用于在负载均衡器中的实例之间分配我的任务.

I'm trying to create an ECS service that distributes my tasks across the instances in the load balancer.

阅读 ECS 负载均衡的文档后,我的理解是我的 ASG 不应该自动向 ELB 注册我的 EC2 实例,因为 ECS 会负责.所以,我的 ASG 没有指定 ELB.同样,我的 ELB 没有任何已注册的 EC2 实例.

After reading the documentation for ECS load balancing, it's my understanding that my ASG should not automatically register my EC2 instances with the ELB, because ECS takes care of that. So, my ASG does not specify an ELB. Likewise, my ELB does not have any registered EC2 instances.

当我创建我的 ECS 服务时,我选择了 ELB,也选择了 ecsServiceRole.创建服务后,我从未在 ECS 实例选项卡中看到任何可用实例.该服务也无法启动任何任务,出现非常普遍的错误...

When I create my ECS service, I choose the ELB and also select the ecsServiceRole. After creating the service, I never see any instances available in the ECS Instances tab. The service also fails to start any tasks, with a very generic error of ...

服务无法放置任务,因为找不到资源.

我已经研究了大约两天了,似乎无法弄清楚哪些配置设置没有正确配置.有没有人对可能导致此无法正常工作的原因有任何想法?

I've been at this for about two days now and can't seem to figure out what configuration settings are not properly configured. Does anybody have any ideas as to what might be causing this to not work?

更新 @ 06/25/2015:

我认为这可能与 ECS_CLUSTER 用户数据设置有关.

I think this may have something to do with the ECS_CLUSTER user data setting.

在我的 EC2 Auto Scaling 启动配置中,如果我将用户数据输入完全留空,则创建的实例的 ECS_CLUSTER 值为default".发生这种情况时,我会看到一个自动创建的集群,名为default".在这个默认集群中,我看到了实例并且可以像预期的那样向 ELB 注册任务.一旦任务在 ELB 中注册并且一切正常,我的 ELB 健康检查 (HTTP) 就通过了.

In my EC2 auto scaling launch configuration, if I leave the user data input completely empty, the instances are created with an ECS_CLUSTER value of "default". When this happens, I see an automatically-created cluster, named "default". In this default cluster, I see the instances and can register tasks with the ELB like expected. My ELB health check (HTTP) passes once the tasks are registered with the ELB and all is good in the world.

但是,如果我将 ECS_CLUSTER 设置更改为自定义设置,我将永远不会看到使用该名称创建的集群.如果我手动创建具有该名称的集群,则这些实例永远不会在集群中可见.在这种情况下,我永远无法向 ELB 注册任务.

But, if I change that ECS_CLUSTER setting to something custom I never see a cluster created with that name. If I manually create a cluster with that name, the instances never become visible within the cluster. I can't ever register tasks with the ELB in this scenario.

有什么想法吗?

推荐答案

最后,我的 EC2 实例没有被分配公共 IP 地址.看来 ECS 需要能够直接与每个 EC2 实例通信,这将要求每个实例都有一个公共 IP.我没有为我的容器实例分配公共 IP 地址,因为我认为我会将它们全部置于公共负载均衡器之后,并且每个容器实例都是私有的.

In the end, it ended up being that my EC2 instances were not being assigned public IP addresses. It appears ECS needs to be able to directly communicate with each EC2 instance, which would require each instance to have a public IP. I was not assigning my container instances public IP addresses because I thought I'd have them all behind a public load balancer, and each container instance would be private.

这篇关于为什么我的 ECS 服务无法向我的 ELB 注册可用的 EC2 实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆