Reputation: 29159
For example, I need to deploy three docker instances to my ECS, which has three EC2. Is it possible to deploy these three docker instances to different EC2 machines?
I'm thinking deploy a kafka cluster, broker1, broker2, broker3 and zookeeper1, zookeeper2, zookeeper3 to three EC2 respectively.
Upvotes: 0
Views: 767
Reputation: 504
You can use the distinctInstance placement constraint to place a service's replica tasks on different instances.
Upvotes: 1
Reputation: 834
Look into daemon services. ECS offers 2 service types - replica and daemon.
PS: Daemon services don't work with Fargate. Doesn't look like you are using Fargate anyway.
Upvotes: 1
Reputation: 8117
If you have BrokerService
, ZooKeeperService
then the tasks will be balanced across availability zones by the spread placement strategy already so this should occur, but it is true that if their wasn't sufficient capacity you might not get the ideal placement.
Fargate Compute
There are a couple of ways to force. The easiest I can think of is if Fargate
was an option. This will ensure the highest level of high availability, but then you are forced to use Fargate, instead of ec2
, which might breach your requirements, as you may for example need block storage which you don't get from Fargate. It could cost or save you money depending on if it would save you needing to deploy new ec2 instances, but you may have reserved instances which you want to use so it depends.
Service Per AZ
Otherwise you could create a service for each AZ. Each service will have a PlacementConstraints
using the Cluster query language to define which zone it should reside in:
"PlacementConstraints": [{
"Type": "memberOf",
"Expression": "attribute:ecs.availability-zone != us-east-1a"
}
You would use us-east-1{a-c}
for each service.
Creating different clusters having different instances in each AZ would also achieve this.
Upvotes: 1