简体   繁体   English

AWS ECS 运行最新任务定义

[英]AWS ECS run latest task definition

I am trying to have run the lastest task definition image built from GitHub deployment (CD).我正在尝试运行从 GitHub 部署 (CD) 构建的最新任务定义映像。 Seems like on AWS it creates a task definition for example " task-api:1 ", " task-api:2 ", on was my cluster is still running task-api: 1 even though there is the latest task as a new image has been built.似乎在 AWS 上它创建了一个任务定义,例如“ task-api:1 ”、“ task-api:2 ”,我的集群仍在运行task-api:1即使有最新的任务作为新图像已建成。 So far I have to manually stop the old one and start a new one.到目前为止,我必须手动停止旧的并启动一个新的。 How can I have it automated?我怎样才能让它自动化?

Judging from what you have said in the comments:从您在评论中所说的话来看:

I created my task via the AWS console, I am running just the task definition on its own without service plus service with task definition launched via the EC2 not target both of them, so in the task definition JSON file on my Github both repositories they are tied to a revision of a task (could that be a problem?).我通过 AWS 控制台创建了我的任务,我只运行自己的任务定义,没有通过 EC2 启动的任务定义的服务和服务,而不是针对它们两者,所以在我的 Github 两个存储库的任务定义 JSON 文件中与任务的修订相关(这可能是个问题吗?)。

It's difficult to understand exactly how you have this set up and it'd probably be a good idea for you to go back and understand the services you are using a little better using the guide you are following or AWS documentation.很难准确了解您是如何进行此设置的,您最好返回 go 并使用您遵循的指南或 AWS 文档更好地了解您正在使用的服务。 Pushing a new task definition does not automatically update services to use the new definition.推送新任务定义不会自动更新服务以使用新定义。

That said, my guess is that you need to update the service in ECS to use the latest task definition.也就是说,我的猜测是您需要更新 ECS 中的服务以使用最新的任务定义。 You can do that in many ways:您可以通过多种方式做到这一点:

This can be automated but you would need to set up a process to automate it.这可以自动化,但您需要设置一个流程来自动化它。

I would recommend reading some guides on how you could automate deployment and updates using the CDK.我建议阅读一些关于如何使用 CDK 自动部署和更新的指南。 Amazon provide a good guide to get you started https://docs.aws.amazon.com/cdk/latest/guide/ecs_example.html .亚马逊提供了一个很好的指南来帮助您入门https://docs.aws.amazon.com/cdk/latest/guide/ecs_example.html

You must wrap your tasks in a service and use rolling updates for automated deployments.您必须将任务包装在服务中,并使用滚动更新进行自动化部署。

When the rolling update (ECS) deployment type is used for your service, when a new service deployment is started the Amazon ECS service scheduler replaces the currently running tasks with new tasks.当滚动更新 (ECS) 部署类型用于您的服务时,当启动新服务部署时,Amazon ECS 服务计划程序会用新任务替换当前正在运行的任务。

Read: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html阅读: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html

This is DevOps, so you need a CI/CD pipeline that will do the rolling updates for you.这就是 DevOps,因此您需要一个 CI/CD 管道来为您进行滚动更新。 Look at CodeBuild, CodeDeploy and CodePipeline (and CodeCommit if you integrate your code repository in AWS with your CI/CD)查看 CodeBuild、CodeDeploy 和 CodePipeline(以及 CodeCommit,如果您将 AWS 中的代码存储库与 CI/CD 集成)

Read: https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-ecs-ecr-codedeploy.html阅读: https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-ecs-ecr-codedeploy.html

This is a complex topic, but it pays off in the end.这是一个复杂的话题,但最终会得到回报。

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

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