EC2实例无法连接到ECS群集

时间:2020-10-17 23:03:34

标签: amazon-web-services amazon-ec2

你好, 我有空的AWS ECS集群,但无法将实例放入其中。 我想使用启动模板和自动缩放组,但是无法分配创建的EC2实例。

问题显示在ecs-agent.log

level=error time=2020-10-17T23:23:37Z msg="Unable to register as a container instance with ECS: RequestError: send request failed\ncaused by: Post \"https://ecs.eu-central-1.amazonaws.com/\": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)" module=client.go
level=error time=2020-10-17T23:23:37Z msg="Error registering: RequestError: send request failed\ncaused by: Post \"https://ecs.eu-central-1.amazonaws.com/\": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)" module=agent.go

注意:

  • 使用AMI ami-0eff571a24849e852
  • 集群名称:debug
  • 区域为eu-central-1
  • 实例没有公共IP
  • 实例位于10.10.100.0/24子网(10.10.100.14)中,VPN子网位于10.10.0.0/16
  • 实例可以通过NAT实例访问Internet:
[ec2-user@ip-10-10-100-14 ecs]$ ping google.com
PING google.com (216.58.212.142) 56(84) bytes of data.
64 bytes from ams15s21-in-f14.1e100.net (216.58.212.142): icmp_seq=1 ttl=109 time=50.1 ms
64 bytes from ams15s21-in-f142.1e100.net (216.58.212.142): icmp_seq=2 ttl=109 time=40.1 ms
  • 外部DNS解决得很好
[ec2-user@ip-10-10-100-14 ecs]$ nslookup google.com
Server:     10.10.0.2
Address:    10.10.0.2#53

Non-authoritative answer:
Name:   google.com
Address: 216.58.212.142
  • 请确定,我已从实例到ECS的VPC和子网创建了端点 VPC-Endpoints
  • 我已附加安全组,没有任何测试限制 security-group
  • ecs.config
ECS_CLUSTER=debug
ECS_BACKEND_HOST=
[ec2-user@ip-10-10-100-14 ecs]$ nslookup ecs.eu-central-1.amazonaws.com
Server:     10.10.0.2
Address:    10.10.0.2#53

Non-authoritative answer:
Name:   ecs.eu-central-1.amazonaws.com
Address: 10.10.100.219

有人有任何建议吗?

1 个答案:

答案 0 :(得分:1)

我已经解决了这个问题。

问题是由VPC端点引起的。我将它们放在错误的子网和安全组中。

我已将它们移动到公共子网(NAT实例旁边的 ),并且与NAT实例位于同一组中(允许来自EC2所在的sg的传入流量

根据文档:

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/vpc-endpoints.html

连接到VPC端点的安全组必须允许来自VPC专用子网的端口443上的传入连接。

相关问题