

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Buat definisi pekerjaan menggunakan EcsProperties
<a name="multi-container-jobs"></a>

Dengan menggunakan definisi AWS Batch pekerjaan [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html), Anda dapat memodelkan perangkat keras, sensor, lingkungan 3D, dan simulasi lainnya dalam wadah terpisah. Anda dapat menggunakan fitur ini untuk secara logis mengatur komponen beban kerja Anda, dan memisahkannya dari aplikasi utama. Fitur ini dapat digunakan AWS Batch di Amazon Elastic Container Service (Amazon ECS), Amazon Elastic Kubernetes Service (Amazon EKS), dan. AWS Fargate

## `ContainerProperties`versus definisi `EcsProperties` pekerjaan
<a name="containerpropertions-vs-ecsproperties"></a>

Anda dapat memilih untuk menggunakan [https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html)atau definisi [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html)pekerjaan sesuai dengan kasus penggunaan Anda. Pada tingkat tinggi, menjalankan AWS Batch pekerjaan dengan `EcsProperties` mirip dengan menjalankan pekerjaan dengan a`ContainerProperties`.

Struktur definisi pekerjaan lama, menggunakan`ContainerProperties`, tetap didukung. Jika saat ini Anda memiliki alur kerja menggunakan struktur ini, Anda dapat terus menjalankannya.

Perbedaan utama adalah bahwa ada objek baru yang ditambahkan ke definisi pekerjaan untuk mengakomodasi definisi `EcsProperties` berbasis.

Misalnya, definisi pekerjaan yang digunakan `ContainerProperties` di Amazon ECS dan Fargate memiliki struktur berikut:

```
{
   "containerProperties": {
     ...
     "image": "my_ecr_image1",
     ...
  },
...
}
```

Definisi pekerjaan yang digunakan `EcsProperties` di Amazon ECS dan Fargate memiliki struktur berikut:

```
{
  "ecsProperties": {
    "taskProperties": [{
      "containers": [
        { 
          ...
          "image": "my_ecr_image1",
          ...
        },
        { 
          ...
          "image": "my_ecr_image2",
          ...
        },
```

## Perubahan umum pada AWS Batch APIs
<a name="multi-container-general"></a>

Berikut ini lebih lanjut menguraikan beberapa perbedaan utama saat menggunakan `ContainerProperties` dan tipe data `EcsProperties` API:
+ Banyak parameter yang digunakan di dalamnya `ContainerProperties` muncul di dalam`TaskContainerProperties`. Beberapa contoh termasuk,`command`,`image`,`privileged`,`secrets`, dan`users`. Mereka semua dapat ditemukan di dalam [TaskContainerProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html).
+ Beberapa `TaskContainerProperties` parameter tidak memiliki ekuivalen fungsional dalam struktur lama. Beberapa contoh termasuk,`dependsOn`,`essential`,`name`,`ipcMode`, dan`pidMode`. Untuk informasi selengkapnya, lihat [EcsTaskDetails](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskDetails.html) dan [TaskContainerProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html).

  Selain itu, beberapa `ContainerProperties` parameter tidak memiliki ekuivalen, atau aplikasi, dalam struktur. `EcsProperties` In [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties), `container` telah diganti dengan `containers` sehingga objek baru dapat menerima hingga sepuluh elemen. [https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-containerProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-containerProperties)
+ `taskRoleArn`secara fungsional setara dengan. `jobRoleArn` Untuk informasi lebih lanjut lihat [EcsTaskProperties: taskRoleArn](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html) dan [ContainerProperties: jobRoleArn](https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerProperties.html).
+ Anda dapat memasukkan dari satu (1) hingga sepuluh (10) wadah dalam `EcsProperties` struktur. [Untuk informasi lebih lanjut lihat:containerEcsTaskProperties.](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html)
+ Objek `taskProperties` dan InstanceTypes adalah array, tetapi saat ini hanya menerima satu elemen. [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html)

## Definisi pekerjaan multi-kontainer untuk Amazon ECS
<a name="multi-container-ecs-updates"></a>

Untuk mengakomodasi struktur multi-kontainer untuk Amazon ECS, beberapa tipe data API berbeda. Misalnya, 
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-ecsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-ecsProperties)adalah level yang sama seperti `containerProperties` dalam definisi kontainer tunggal. Untuk informasi selengkapnya, lihat [EcsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html)di *Panduan Referensi AWS Batch API*.
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html#Batch-Type-EcsProperties-taskProperties)berisi properti yang ditentukan untuk tugas Amazon ECS. Untuk informasi selengkapnya, lihat [EcsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsProperties.html)di *Panduan Referensi AWS Batch API*.
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html#Batch-Type-EcsTaskProperties-containers](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html#Batch-Type-EcsTaskProperties-containers)mencakup informasi serupa dengan definisi kontainer tunggal. `containerProperties` Perbedaan utamanya adalah `containers` memungkinkan Anda menentukan hingga sepuluh kontainer. Untuk informasi selengkapnya, lihat [ECSTaskProperti: Kontainer](https://docs.aws.amazon.com/batch/latest/APIReference/API_EcsTaskProperties.html) di Panduan *Referensi AWS Batch API*.
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-essential](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-essential)parameter menunjukkan bagaimana wadah mempengaruhi pekerjaan. Semua kontainer penting harus berhasil diselesaikan (keluar sebagai 0) agar pekerjaan dapat berkembang. Jika wadah yang ditandai sebagai esensial gagal (keluar sebagai non-0), maka pekerjaan gagal.

  Nilai defaultnya adalah `true` dan setidaknya satu kontainer harus ditandai sebagai`essential`. Untuk informasi selengkapnya, lihat [https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-essential](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-essential)di *Panduan Referensi AWS Batch API*.
+ Dengan [https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-dependsOn](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-dependsOn)parameter, Anda dapat menentukan daftar dependensi kontainer. Untuk informasi selengkapnya, lihat [https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-dependsOn](https://docs.aws.amazon.com/batch/latest/APIReference/API_TaskContainerProperties.html#Batch-Type-TaskContainerProperties-dependsOn)di *Panduan Referensi AWS Batch API*.
**catatan**  
Kompleksitas `dependsOn` daftar dan runtime kontainer terkait dapat memengaruhi waktu mulai untuk pekerjaan Anda. Jika dependensi membutuhkan waktu lama untuk dijalankan, pekerjaan akan tetap dalam `STARTING` keadaan sampai selesai.

Untuk informasi selengkapnya tentang struktur `ecsProperties` dan, lihat sintaks [RegisterJobDefinition](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#API_RegisterJobDefinition_RequestBody)permintaan untuk [ecsProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-ecsProperties).

## Definisi pekerjaan multi-kontainer untuk Amazon EKS
<a name="multi-container-eks-updates"></a>

Untuk mengakomodasi struktur multi-container untuk Amazon EKS, beberapa tipe data API berbeda. Misalnya, 
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EksContainer.html#Batch-Type-EksContainer-name](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksContainer.html#Batch-Type-EksContainer-name)adalah pengidentifikasi unik untuk wadah. Objek ini tidak diperlukan untuk satu kontainer, tetapi diperlukan saat mendefinisikan beberapa kontainer dalam sebuah pod. Ketika `name` tidak ditentukan untuk kontainer tunggal, nama default`default`,, diterapkan.
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-initContainers](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-initContainers)didefinisikan dalam tipe [eksPodProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html)data. Mereka berjalan sebelum wadah aplikasi, selalu berjalan hingga selesai, dan harus berhasil diselesaikan sebelum penampung berikutnya dimulai.

  Kontainer ini terdaftar di agen Amazon EKS Connector dan menyimpan informasi pendaftaran di toko data backend Amazon Elastic Kubernetes Service. `initContainers`Objek dapat menerima hingga sepuluh (10) elemen. Untuk informasi selengkapnya, lihat [Init Containers](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) dalam *Kubernetesdokumentasi*.
**catatan**  
`initContainers`Objek dapat mempengaruhi waktu mulai untuk pekerjaan Anda. Jika `initContainers` butuh waktu lama untuk menjalankan, pekerjaan akan tetap dalam `STARTING` keadaan sampai mereka selesai.
+ [https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-shareProcessNamespace](https://docs.aws.amazon.com/batch/latest/APIReference/API_EksPodProperties.html#Batch-Type-EksPodProperties-shareProcessNamespace)menunjukkan apakah kontainer di pod dapat berbagi namespace proses yang sama. Nilai defaultnya adalah`false`. Menyetel ini `true` untuk mengaktifkan kontainer melihat dan memberi sinyal proses di wadah lain yang terletak di pod yang sama.
+ Setiap wadah memiliki kepentingan. Semua kontainer harus berhasil diselesaikan (keluar sebagai 0) agar pekerjaan berhasil. Jika satu kontainer gagal (keluar sebagai selain 0), maka pekerjaan gagal.

Untuk informasi selengkapnya tentang struktur `eksProperties` dan, lihat sintaks [RegisterJobDefinition](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#API_RegisterJobDefinition_RequestBody)permintaan untuk [eksProperties](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html#Batch-RegisterJobDefinition-request-eksProperties).

# Referensi: skenario AWS Batch pekerjaan menggunakan EcsProperties
<a name="multi-container-jobs-scenarios"></a>

Untuk mengilustrasikan bagaimana definisi AWS Batch pekerjaan yang digunakan `EcsProperties` dapat disusun berdasarkan kebutuhan Anda, topik ini menyajikan [https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html)muatan berikut. Anda dapat menyalin contoh-contoh ini ke dalam file, menyesuaikannya dengan kebutuhan Anda, dan kemudian menggunakan AWS Command Line Interface (AWS CLI) untuk memanggil`RegisterJobDefinition`.

## AWS Batch pekerjaan untuk Amazon ECS di Amazon EC2
<a name="multi-container-scenario-on-ec2"></a>

Berikut ini adalah contoh AWS Batch pekerjaan untuk Amazon Elastic Container Service di Amazon Elastic Compute Cloud:

```
{
    "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": false,
                "command": [
                  "echo",
                  "hello world"
                ],
                "image": "public.ecr.aws/amazonlinux/amazonlinux:latest",
                "resourceRequirements": [
                  {
                    "type": "VCPU",
                    "value": "2"
                  },
                  {
                    "type": "MEMORY",
                    "value": "4096"
                  }
                ]
              },
              {
                "name": "c3",
                "essential": true,
                "command": [
                  "echo",
                  "hello world"
                ],
                "image": "public.ecr.aws/amazonlinux/amazonlinux:latest",
                "firelensConfiguration": {
                  "type": "fluentbit",
                  "options": {
                    "enable-ecs-log-metadata": "true"
                  }
                 },
                "resourceRequirements": [
                  {
                    "type": "VCPU",
                    "value": "6"
                  },
                  {
                    "type": "MEMORY",
                    "value": "12288"
                  }
                ]
              }
            ]
          }
        ]
  }
}
```

## AWS Batch pekerjaan untuk Amazon ECS di Fargate
<a name="multi-containers-ecs-on-fargate"></a>

Berikut ini adalah contoh AWS Batch pekerjaan untuk Amazon Elastic Container Service di AWS 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"
          }
        ]
  }
}
```

## AWS Batch pekerjaan untuk Amazon EKS
<a name="multi-containers-eks-example"></a>

Berikut ini adalah contoh AWS Batch pekerjaan untuk Amazon 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"
            }
          }
        }
      ]
    }
  }
}
```

## AWS Batch Pekerjaan MNP dengan beberapa kontainer per node
<a name="multi-container-ecs-mnp"></a>

Berikut ini adalah contoh AWS Batch pekerjaan multi-node parallel (MNP) dengan beberapa kontainer per node:

```
{
  "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"
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}
```