AWS ECS CLI不;t将EC2实例附加到群集



我有一些docker容器,我正试图使用ECS CLI在AWS ECS上启动它们。

这些是我的命令:

ecs-cli configure --cluster abc --default-launch-type FARGATE --config-name abc-conf --region eu-west-1

ecs-cli configure profile --access-key xxx --secret-key xxx --profile-name abc-profile

ecs-cli up --security-group sg-094607105993d0351 --vpc vpc-0479323e6e7107b74 --subnets subnet-009eb5c6e08b7dbf0,subnet-0e1c2846b268b170a --keypair abc-key --capability-iam --size 1 --instance-type t2.small --cluster-config abc-conf --ecs-profile abc-profile --region eu-west-1 --force

ecs-cli compose up --create-log-groups --cluster-config abc-conf --ecs-profile abc-profile --create-log-groups

但是我得到

ERRO[0001] Error running tasks                           error="InvalidParameterException:     No Container Instances were found in your cluster." task definition=0xc00031e6a0
FATA[0001] InvalidParameterException: No Container Instances were found in your cluster. 

原因是ecs-cli up命令正在引发EC2,但没有将其带入集群中,因此集群没有实例。

现在,如果我不指定自己的vpc和子网,这就可以了,但我必须这样做,因为没有其他方法可以指定要在集群上打开的一组端口(有一个选项只允许您指定一个端口(。

那么为什么ecs-cli没有将我的实例带入集群中呢

终于找到了答案。您必须在专有网络中添加一个互联网网关;然后,在您试图启动集群的子网中,您必须添加一个指向互联网网关0.0.0.0/0的路由表条目。然后它会立即将ec2连接到您的集群。

我不确定您是否在实例上正确配置了user-data。您应该将其配置为在ECS集群启动时加入。

#!/bin/bash
echo "ECS_CLUSTER=MyCluster" >> /etc/ecs/ecs.config

文档中的更多信息。

此外,如果您不使用AWS ECS Optimized AMI,则可能需要进行更多配置。

最新更新