简体   繁体   English

在 2 个容器实例(ECS 实例)上运行 ECS 服务

[英]Running ECS service on 2 container instances (ECS instances)

I have an ECS service which has a requirement that it should be running on exactly 2 container instances.我有一个 ECS 服务,它要求它应该恰好在 2 个容器实例上运行。 How can this be achieved?如何实现? I could not find any specific place in container definition, where I can fix the number of ECS instances.我在容器定义中找不到任何特定位置,我可以在其中固定 ECS 实例的数量。

There are a few ways to achieve this.有几种方法可以实现这一点。 One is to deploy your ECS service on Fargate.一种是在 Fargate 上部署您的 ECS 服务。 When you do so and you set your task count to, say, 2... ECS will deploy your 2 tasks onto 2 separate and dedicated operating systems/VMs managed by AWS.当您这样做并将任务计数设置为 2 时……ECS 会将您的 2 个任务部署到由 AWS 管理的 2 个独立且专用的操作系统/VM 上。 Two or more tasks can never be colocated to one of these VMs.永远不能将两个或更多任务并置到这些 VM 之一。 It's always a 1 task: 1 VM relationship.它始终是 1 个任务:1 个 VM 关系。

If you are using EC2 as your launch type and you want to make sure your service deploys exactly 1 task per instance the easiest way would be to configure your ECS service as type DAEMON .如果您使用 EC2 作为启动类型,并且希望确保您的服务为每个实例准确部署 1 个任务,最简单的方法是将您的 ECS 服务配置为DAEMON类型。 In this case you don't even need (or can't) configure the number of tasks in your service because ECS will always deploy 1 task per EC2 instance that is part of the cluster.在这种情况下,您甚至不需要(或不能)配置服务中的任务数量,因为 ECS 将始终为属于集群的每个 EC2 实例部署 1 个任务。

At the time of creating service you will find the field Number of tasks it means that how many container you want exactly.在创建服务时,您会发现任务数字段,它表示您确切需要多少个容器。 If you write 1 than it will launch only 1 and if you write 2 then it will launch 2. I Hope you understand如果你写 1,它只会启动 1,如果你写 2,它会启动 2。我希望你能理解

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

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