Amazon Batch 使用的工作场景 EcsProperties - Amazon Batch
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Amazon Batch 使用的工作场景 EcsProperties

为了说明如何根据您的需求来构造所使用的 Amazon Batch EcsProperties任务定义,本主题介绍了以下RegisterJobDefinition负载。您可以将这些示例复制到文件中,根据需要对其进行自定义,然后使用 Amazon Command Line Interface (Amazon CLI) 进行调用RegisterJobDefinition

Amazon Batch 亚马逊弹性容器服务在亚马逊弹性计算云上的工作

{ "jobDefinitionName": "multicontainer-ecs-ec2", "type": "container", "ecsProperties": { "taskProperties": [ { "containers": [ { "name": "c1", "essential": false, "command": [ "echo", "hello world" ], "image": "public.ecr.aws/amazonlinux/amazonlinux:latest", "resourceRequirements": [ { "type": "VCPU", "value": "2" }, { "type": "MEMORY", "value": "4096" } ] }, { "name": "c2", "essential": true, "command": [ "echo", "hello world" ], "image": "public.ecr.aws/amazonlinux/amazonlinux:latest", "resourceRequirements": [ { "type": "VCPU", "value": "6" }, { "type": "MEMORY", "value": "12288" } ] } ] } ] } }

Amazon Batch 在 Amazon ECS 上工作 Amazon Fargate

{ "jobDefinitionName": "multicontainer-ecs-fargate", "type": "container", "platformCapabilities": [ "FARGATE" ], "ecsProperties": { "taskProperties": [ { "containers": [ { "name": "c1", "command": [ "echo", "hello world" ], "image": "public.ecr.aws/amazonlinux/amazonlinux:latest", "resourceRequirements": [ { "type": "VCPU", "value": "2" }, { "type": "MEMORY", "value": "4096" } ] }, { "name": "c2", "essential": true, "command": [ "echo", "hello world" ], "image": "public.ecr.aws/amazonlinux/amazonlinux:latest", "resourceRequirements": [ { "type": "VCPU", "value": "6" }, { "type": "MEMORY", "value": "12288" } ] } ], "executionRoleArn": "arn:aws:iam::1112223333:role/ecsTaskExecutionRole" } ] } }

Amazon Batch 亚马逊 Elastic Kubernetes Service 的工作

{ "jobDefinitionName": "multicontainer-eks", "type": "container", "eksProperties": { "podProperties": { "shareProcessNamespace": true, "initContainers": [ { "name": "init-container", "image": "public.ecr.aws/amazonlinux/amazonlinux:2", "command": [ "echo" ], "args": [ "hello world" ], "resources": { "requests": { "cpu": "1", "memory": "512Mi" } } }, { "name": "init-container-2", "image": "public.ecr.aws/amazonlinux/amazonlinux:2", "command": [ "echo", "my second init container" ], "resources": { "requests": { "cpu": "1", "memory": "512Mi" } } } ], "containers": [ { "name": "c1", "image": "public.ecr.aws/amazonlinux/amazonlinux:2", "command": [ "echo world" ], "resources": { "requests": { "cpu": "1", "memory": "512Mi" } } }, { "name": "sleep-container", "image": "public.ecr.aws/amazonlinux/amazonlinux:2", "command": [ "sleep", "20" ], "resources": { "requests": { "cpu": "1", "memory": "512Mi" } } } ] } } }

多节点并行 (MNP) Amazon Batch 作业,每个节点有多个容器

{ "jobDefinitionName": "multicontainer-mnp", "type": "multinode", "nodeProperties": { "numNodes": 6, "mainNode": 0, "nodeRangeProperties": [ { "targetNodes": "0:5", "ecsProperties": { "taskProperties": [ { "containers": [ { "name": "range05-c1", "command": [ "echo", "hello world" ], "image": "public.ecr.aws/amazonlinux/amazonlinux:latest", "resourceRequirements": [ { "type": "VCPU", "value": "2" }, { "type": "MEMORY", "value": "4096" } ] }, { "name": "range05-c2", "command": [ "echo", "hello world" ], "image": "public.ecr.aws/amazonlinux/amazonlinux:latest", "resourceRequirements": [ { "type": "VCPU", "value": "2" }, { "type": "MEMORY", "value": "4096" } ] } ] } ] } } ] } }