【问题标题】:Update the task definition of a fargate scheduled task in ECS cluster更新 ECS 集群中 Fargate 定时任务的任务定义
【发布时间】:2020-07-22 05:32:16
【问题描述】:

我有一个到 ecs 集群的管道设置,我在其中更新服务的任务定义,然后启动新的部署。例如:

# Update task definition
- aws ecs register-task-definition --cli-input-json file://aws/task-definition${TASK_SUFFIX}.json --region $AWS_DEFAULT_REGION
- TASK_REVISION=`aws ecs describe-task-definition --task-definition ${SERVICE_NAME}${TASK_SUFFIX} | egrep "revision" | tr "/" " " | awk '{print $2}' | sed 's/"$//'`

# Request service update:
- aws ecs update-service --service ${SERVICE_NAME} --cluster ${CLUSTER_NAME} --task-definition ${SERVICE_NAME}${TASK_SUFFIX}:${TASK_REVISION} --force-new-deployment

我有一个计划任务,它使用服务的相同任务定义,两者都使用 Fargate。但是,当我更新我的服务的任务定义时,我必须手动将我的计划任务更新到最新版本。

每当我更新我的服务的任务定义时,我想将我的计划任务的任务定义更新为最新版本。可能吗?

【问题讨论】:

  • 你找到解决办法了吗?

标签: amazon-web-services scheduled-tasks amazon-ecs aws-fargate


【解决方案1】:

所以对我来说这是有效的

   aws events put-targets --cli-input-json file://.app_generic.json

app_generic.json

{
  "Rule": "rule--app--generic",
  "Targets": [
    {
      "Id": "app--generic",
      "Arn": "arn:aws:ecs:us-east-1:xxxxxxx:cluster/my-cluster",
      "RoleArn": "arn:aws:iam::xxxxxxx:role/ecsEventsRole",
      "EcsParameters": {
        "TaskDefinitionArn": "arn:aws:ecs:us-east-1:xxxxxxxx:task-definition/my-task-definitions",
        "TaskCount": 1,
        "LaunchType": "FARGATE",
        "NetworkConfiguration": {
          "awsvpcConfiguration": {
            "Subnets": [
              "subnet-xxxxx"
            ],
            "SecurityGroups": [
              "sg-xxxxxxx"
            ],
            "AssignPublicIp": "ENABLED"
          }
        },
        "PlatformVersion": "1.4.0"
      }
    }
  ]
}

基本上我必须重新制定规则,但是通过在 TaskDefinitionArn 中省略修订号,它会更新为最新修订,而其他容器参数(命令、环境变量等)仍然存在。我想这在技术上仍然是“手动”的,但是该命令可以在 CI/CD、bash 脚本等中的服务更新后添加。

【讨论】:

  • 我仍然愿意接受更好的解决方案,但是,这只是挽救了我的虚拟生活,谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-26
  • 2020-10-04
  • 2019-06-08
  • 1970-01-01
  • 2019-09-10
  • 1970-01-01
相关资源
最近更新 更多