简体   繁体   English

Amazon ECS:如何调度容器?

[英]Amazon ECS : how to schedule a container?

I have a very simple ECS cluster using Fargate.我有一个使用 Fargate 的非常简单的 ECS 集群。 I'd like to schedule a container to be run using a cron expression.我想安排一个容器使用 cron 表达式运行。

I created the task definition and a rule pointing to it using the EventBridge console, but I see nothing getting launched on the cluster.我使用 EventBridge 控制台创建了任务定义和指向它的规则,但我没有看到任何东西在集群上启动。 No logs, not even a trace of anything starting apart from the "monitor" tab of the rule which says it was triggered (but then again, I don't see any logs).没有日志,甚至没有任何从规则的“监控”选项卡开始的任何痕迹,该选项卡表示它已被触发(但话又说回来,我没有看到任何日志)。

I'm guessing this might have to do with the public IP somehow needed for the rule to pull the container using Fargate?我猜这可能与 public IP 以某种方式需要使用 Fargate 拉容器的规则有关? In the creation there is a setting called auto-assign public IP address but it only shows the DISABLED option.在创建过程中,有一个名为auto-assign public IP address的设置,但它只显示DISABLED选项。

Has anyone had the same problem?有没有人有同样的问题? Should I just schedule a normal service with sleep times of 24hours between executions and risk a higher cost?我是否应该安排一个正常的服务,每次执行之间的休眠时间为 24 小时,并冒着更高成本的风险? Cheers干杯

Since you mention that you have no issues running the task manually in the cluster, it's likely that the problem with EventBridge is that the role associated with the rule does not have enough permissions to run the task.由于您提到在集群中手动运行任务没有问题,因此 EventBridge 的问题很可能是与规则关联的角色没有足够的权限来运行任务。

You can confirm this by checking CloudTrail logs.您可以通过检查 CloudTrail 日志来确认这一点。 You'll find a RunTask event with a failure similar to the following:您会发现一个RunTask事件,其失败类似于以下内容:

User: arn:aws:sts::xxxx:assumed-role/Amazon_EventBridge_Invoke_ECS/xxx is not authorized to perform: ecs:RunTask on resource: arn:aws:ecs:us-east-1:xxxx:task-definition/ECS_task

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM