简体   繁体   English

带有更新映像的AWS Deploy ECS

[英]AWS Deploy ECS with Updated Image

It appears that one must provide a new full task definition for each service update. 似乎必须为每个服务更新提供一个新的完整任务定义。 Even though most of the time new deployments exclusively consists of updates to one of the underlying docker images 即使大多数情况下,新部署只包括对基础docker映像之一的更新

While this is understandable as a core architectural choice. 虽然这可以理解为核心架构选择。 It is quite cumbersome. 这很麻烦。 Is there a command-line option that makes this easier as the full JSON spec for task definitions are quite complex? 是否有命令行选项可以使此操作变得容易,因为任务定义的完整JSON规范非常复杂?

Right now the developers needs to provide complex scripts and deployment orchestrations to achieve this relatively routine task in their CI/CD processes 现在,开发人员需要提供复杂的脚本和部署流程,以在其CI / CD流程中完成此相对常规的任务

I see attempts at this Here and Here . 我在这里这里看到了尝试。 These solutions do not appear to work in all cases (for example, for Fargate launches) 这些解决方案似乎并非在所有情况下都有效(例如,对于Fargate发射)

I know that if the updated image uses the re-use the same tag this problem is made easier, however in dev cultures that values reproducibility and audibility that is simply not an reasonable option 我知道,如果更新的图像使用重复使用相同的标签,这个问题将变得更加容易,但是在开发文化中,重视可重复性和可听性的选择根本不是一个合理的选择。

Is there no other option than to leverage both the AWS API & JSON manipulation libraries? 除了同时利用AWS API和JSON操作库之外,没有其他选择吗?

EDIT It appears this project does a fairly good job https://github.com/fabfuel/ecs-deploy 编辑看来这个项目做得相当不错https://github.com/fabfuel/ecs-deploy

I found a few approaches 我发现了几种方法

  1. As mentioned in my comment, use ecs-deploy script per the Github link 如我的评论所述,每个Github链接使用ecs-deploy脚本

  2. Create a task definition via the --generate-cli-skeleton option on awscli. 通过--generate-cli-skeleton上的--generate-cli-skeleton选项创建任务定义。 Fill out all details except for execution-rule-arn , task-role-arn , image 填写除执行规则学习任务角色学习图像之外的所有详细信息

These cannot be filled out because they will change per commit or per environment you want to deploy to 无法填写这些内容,因为它们将随您要部署到的每个提交或每个环境而变化

Commit this skeleton to git , so it is part of your workspace on the CI 将此骨架提交给git ,因此它是CI上工作区的一部分

Then use a JSON traversing/parsing library or utility such as https://jqplay.org/ to replace at build time on the CI the roleArn and image name 然后使用JSON遍历/解析库或实用程序(例如https://jqplay.org/)在CI上的构建时替换roleArn和图像名称

Use https://github.com/fabfuel/ecs-deploy . 使用https://github.com/fabfuel/ecs-deploy

If you want to update only the tag of an existent task: 如果只想更新现有任务的标签:

ecs deploy <CLUSTER NAME> <SERVICE NAME> --region <REGION NAME> --tag <NEW TAG>

eg ecs deploy default web-service --region us-east-1 --tag v2.0 例如 ecs deploy default web-service --region us-east-1 --tag v2.0

In your ci/cd you use git hash: Using git rev-parse HEAD , will return a hash like: d63c16cd4d0c9a30524c682fe4e7d417faae98c9 在您的ci / cd中,您使用git hash:使用git rev-parse HEAD ,将返回一个哈希,例如: d63c16cd4d0c9a30524c682fe4e7d417faae98c9

docker build -t image-name:$(git rev-parse HEAD) .
docker push image-name:$(git rev-parse HEAD)

And use the same tag on task: 并在任务上使用相同的标签:

ecs deploy default web-service --region us-east-1 --tag $(git rev-parse HEAD)

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

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