Tutorial: Create a managed compute environment using Amazon EKS resources
Complete the following steps to create a managed compute environment using Amazon Elastic Kubernetes Service (Amazon EKS) resources.
-
Open the Amazon Batch console at https://console.amazonaws.cn/batch/
. -
From the navigation bar, select the Amazon Web Services Region to use.
-
In the navigation pane, choose Compute environments.
-
Choose Create.
-
For Compute environment configuration, choose Amazon Elastic Kubernetes Service (Amazon EKS).
-
For Name, specify a unique name for your compute environment. The name can be up to 128 characters in length. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).
-
For Instance role, choose an existing instance profile that has the required IAM permissions attached.
Note
To create a compute environment in the Amazon Batch console, choose an instance profile that has the
eks:ListClusters
andeks:DescribeCluster
permissions. -
For EKS cluster, choose an existing Amazon EKS cluster.
-
For Namespace, enter a Kubernetes namespace to group your Amazon Batch processes in the cluster.
-
(Optional) Expand Tags. Choose Add tag and then enter a key-value pair.
-
Choose Next page.
-
(Optional) For Use EC2 Spot Instances, turn on Enable using Spot instances to use Amazon EC2 Spot Instances.
-
(Spot only) For Maximum % on-demand price, choose the maximum percentage that a Spot Instance price can be when compared with the On-Demand price for that instance type before instances are launched. For example, if your maximum price is 20%, then the Spot price must be less than 20% of the current On-Demand price for that EC2 instance. You always pay the lowest (market) price and never more than your maximum percentage. If you leave this field empty, the default value is 100% of the On-Demand price.
-
(Spot only) For Spot fleet role, choose the Amazon EC2 Spot fleet IAM role for the
SPOT
compute environment.Important
This role is required if the allocation strategy is set to
BEST_FIT
or not specified. -
(Optional) For Minimum vCPUs, choose the minimum number of vCPUs that your compute environment maintains, regardless of job queue demand.
-
(Optional) For Maximum vCPUs, choose the maximum number of vCPUs that your compute environment can scale out to, regardless of job queue demand.
-
For Allowed instance types, choose the Amazon EC2 instance types that can be launched. You can specify instance families to launch any instance type within those families (for example,
c5
,c5n
, orp3
). Or, you can specify specific sizes within a family (such asc5.8xlarge
). Metal instance types aren't in the instance families. For example,c5
doesn't includec5.metal
.Amazon Batch can select the instance type for you if you choose one of the following:
optimal
to select instance types (from thec4
,m4
,r4
,c5
,m5
, andr5
instance families) that match the demand of your job queues.default_x86_64
to choose x86 based instance types (from the m6i, c6i, r6i, and c7i instance families) that matches the resource demands of the job queue.default_arm64
to choose x86 based instance types (from the m6g, c6g, r6g, and c7g instance families) that matches the resource demands of the job queue.
Note
Starting on 11/01/2025 the behavior of
optimal
is going to be changed to matchdefault_x86_64
. During the change your instance families could be updated to a newer generation. You do not need to perform any actions for the upgrade to happen. For more information about change, see Optimal instance type configuration to receive automatic instance family updates.Note
Instance family availability varies by Amazon Web Services Region. For example, some Amazon Web Services Regions may not have any fourth generation instance families but have fifth and sixth generation instance families.
-
When using
default_x86_64
ordefault_arm64
instance bundles, Amazon Batch selects instance families based on a balance of cost-effectiveness and performance. While newer generation instances often provide better price-performance, Amazon Batch may choose an earlier generation instance family if it provides the optimal combination of availability, cost, and performance for your workload. For example, in an Amazon Web Services Region where both c6i and c7i instances are available, Amazon Batch might select c6i instances if they offer better cost-effectiveness for your specific job requirements. For more information on Amazon Batch instance types and Amazon Web Services Region availability, see Instance type compute table. Amazon Batch periodically updates your instances in default bundles to newer, more cost-effective options. Updates happen automatically without requiring any action from you. Your workloads continue running during updates with no interruption
Note
When you create a compute environment, the instance types that you select for the compute environment must share the same architecture. For example, you can't mix x86 and ARM instances in the same compute environment.
Note
Amazon Batch will scale GPUs based on the required amount in your job queues. To use GPU scheduling, the compute environment must include instance types from the
p3
,p4
,p5
,p6
,g3
,g3s
,g4
,g5
, org6
families. -
(Optional) Expand Additional configuration.
-
(Optional) For Placement group, enter a placement group name to group resources in the compute environment.
-
For Allocation strategy, choose BEST_FIT_PROGRESSIVE.
-
(Optional) For Amazon Machine Images (AMIs) Configuration, choose Add amazon machine images (amis) configuration.
You can use either an Amazon EKS-optimized Amazon Linux AMI or a custom AMI.
-
To use an Amazon EKS-optimized Amazon Linux AMI:
-
For Image type choose one of the following:
Amazon Linux 2: Default for all Amazon Graviton-based instance families (for example,
C6g
,M6g
,R6g
, andT4g
) and can be used for all non-GPU instance types.Amazon Linux 2 (accelerated): Default for all GPU instance families (for example,
P4
andG4
) and can be used for all non Amazon Graviton-based instance types.Amazon Linux 2023: Amazon Batch supports Amazon Linux 2023 (AL2023).
Amazon Linux 2023 (accelerated): GPU instance families and can be used for all non Amazon Graviton-based instance types.
-
For Kubernetes version enter in a Kubernetes version number.
-
-
To use a custom AMI:
For Image type choose the AMI type that the custom AMI is based off of:
Amazon Linux 2: Default for all Amazon Graviton-based instance families (for example,
C6g
,M6g
,R6g
, andT4g
) and can be used for all non-GPU instance types.Amazon Linux 2 (accelerated): Default for all GPU instance families (for example,
P4
andG4
) and can be used for all non Amazon Graviton-based instance types.Amazon Linux 2023: Amazon Batch supports AL2023.
Amazon Linux 2023 (accelerated): GPU instance families and can be used for all non Amazon Graviton-based instance types.
For Image ID override enter the custom AMI ID.
-
For Kubernetes version enter in a Kubernetes version number.
-
-
(Optional) For Launch template, choose an existing launch template.
-
(Optional) For Launch template version, enter
$Default
,$Latest
, or a version number. -
(Optional) For Override launch template, to add an override choose Add override Launch template:
-
(Optional) For Launch template choose the launch template to add the override to.
-
(Optional) For Launch template version choose the version number of the launch template,
$Default
, or$Latest
. -
(Optional) For Target instances types choose the instance type or family that this override should be applied to. This can target only instance types and families that are included in Allowed instance types.
-
(Optional) For userdataType choose the EKS node initialization. Only use this field if you have an AMI specified in either the Launch Template or as a Launch Template Override. Choose EKS_NODEADM for custom AMIs based on
EKS_AL2023
orEKS_AL2023_NVIDIA
or EKS_BOOSTRAP_SH forEKS_AL2
andEKS_AL_NVIDIA
. The default value is EKS_BOOSTRAP_SH.You would use userdataType when you have a mixed environment where you're using both AL2 and AL2023-based custom AMIs in the same compute environment.
-
-
-
Choose Next page.
-
For Virtual Private Cloud (VPC) ID, choose a VPC where to launch the instances.
-
For Subnets, choose the subnets to use. By default, all subnets within the selected VPC are available.
Note
Amazon Batch on Amazon EKS supports Local Zones. For more information, see Amazon EKS and Amazon Local Zones in the Amazon EKS User Guide.
-
(Optional) For Security groups, choose a security group to attach to your instances. By default, the default security group for your VPC is selected.
-
Choose Next page.
-
For Review, review the configuration steps. If you need to make changes, choose Edit. When you're finished, choose Create compute environment.