容量提供程序是否附加到`cluster`而不是`service`或`taskdefinition`?

huangapple go评论50阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年5月14日 13:16:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245954.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定