英文:
Is Capacity Provider attached to `cluster` not `service` or `taskdefinition`?
问题
I am using ECS on EC2
What I want to do is like this below.
-
task1 (admin task - light)
- nginx container
- django python framework container
-
task2 (AI task - heavy)
- api container (access from django container in task1 only)
- AI model container
So my idea is
cluster - service1 - taskdefinition1 - task1 (use small instance)
- service2 - taskdefinition2 - task2 (use big instance)
then At first, I made one capacity provider
for admin task
const adminAutoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: new ec2.InstanceType('t2.small'),
machineImage: ecs.EcsOptimizedImage.amazonLinux(),
autoScalingGroupName: 'ol-${targetEnv}-asg',
minCapacity: 1,
maxCapacity: 3,
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC }
});
const adminCapacityProvider = new ecs.AsgCapacityProvider(this, 'AsgCapacityProvider', {
autoScalingGroup: adminAutoScalingGroup,
capacityProviderName: 'admin-${targetEnv}-cp'
});
cluster.addAsgCapacityProvider(adminCapacityProvider);// it is attached to cluster?????
I am confused.
capacityprovider
should be attached to cluster
not service
or taskdefinition
?
If so, is my idea (make two capacity providers and attach each to each task or service) wrong?.
Is there any best practice for this case?(including fargate)
英文:
I am using ECS on EC2
What I want to do is like this below.
-
task1 (admin task - light)
- nginx container
- django python framework container
-
task2 (AI task - heavy)
- api container (access from django container in task1 only)
- AI model container
So my idea is
cluster - service1 - taskdefinition1 - task1 (use small instance)
- service2 - taskdefinition2 - task2 (use big instance)
then At first, I made one capacity provider
for admin task
const adminAutoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: new ec2.InstanceType('t2.small'),
machineImage: ecs.EcsOptimizedImage.amazonLinux(),
autoScalingGroupName:`ol-${targetEnv}-asg`,
minCapacity:1,
maxCapacity:3,
vpcSubnets: {subnetType: ec2.SubnetType.PUBLIC }
});
const adminCapacityProvider = new ecs.AsgCapacityProvider(this, 'AsgCapacityProvider', {
autoScalingGroup:adminAutoScalingGroup,
capacityProviderName: `admin-${targetEnv}-cp`
});
cluster.addAsgCapacityProvider(adminCapacityProvider);// it is attached to cluster?????
I am confused.
capacityprovider
should be attached to cluster
not service
or taskdefinition
?
If so, is my idea (make two capacity providers and attach each to each task or service) wrong?.
Is there any best practice for this case?(including fargate)
答案1
得分: 1
capacityProvider
是为集群定义的。但是一个集群可以有多个容量提供者。因此,在您的服务中,您可以定义 capacityProviderStrategy,它可以在集群中选择不同的提供者。
英文:
capacityprovider
are defined for clusters. But a cluster can have multiple capacity providers. Thus in your service you can define capacityProviderStrategy which can choose between different providers in the cluster.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论