本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
自定义 Amazon EKS 启动模板
Amazon Batch 在 Amazon 上,EKS 支持启动模板。启动模板的功能受到限制。
重要
对于 EKS 来说 AL2 AMIs, Amazon Batch 跑步
/etc/eks/bootstrap.sh。请勿在启动模板或cloud-inituser-data脚本中运行/etc/eks/bootstrap.sh。除了 bootstrap.sh的 --kubelet-extra-args参数外,还可以添加其他参数。为此,请在AWS_BATCH_KUBELET_EXTRA_ARGS文件中设置/etc/aws-batch/batch.config变量。详情请参阅以下示例。-
对于 EKS AL2 023, Amazon Batch 利用来NodeConfigSpec
自 EKS 的使实例加入 EKS 集群。 Amazon Batch 将NodeConfigSpec 为 EKS 集群填充 ClusterDetails ,您无需指定它们。
注意
我们建议您不要在启动模板中NodeConfigSpec
TaintsCluster NameapiServerEndpointcertificatAuthorityCIDR不要创建带有前缀的标签
batch.amazonaws.com/
注意
如果在调用后CreateComputeEnvironment更改了启动模板,则UpdateComputeEnvironment必须调用该启动模板来评估要替换的启动模板的版本。
添加 kubelet 额外参数
Amazon Batch 支持向kubelet命令添加额外的参数。有关支持的参数列表,请参阅Kubernetes文档中的kubelet,已添加到--node-labels
mylabel=helloworldkubelet命令行中。
MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" --==MYBOUNDARY== Content-Type: text/x-shellscript; charset="us-ascii" #!/bin/bash mkdir -p /etc/aws-batch echo AWS_BATCH_KUBELET_EXTRA_ARGS=\"--node-labels mylabel=helloworld\" >> /etc/aws-batch/batch.config --==MYBOUNDARY==--
对于 EKS AL2 023 AMIs ,文件格式为 YAML。有关支持的参数列表,请参阅Kubernetes文档中的NodeConfigSpec,已添加到--node-labels
mylabel=helloworldkubelet命令行中。
MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" --==MYBOUNDARY== Content-Type: application/node.eks.aws apiVersion: node.eks.aws/v1alpha1 kind: NodeConfig spec: kubelet: flags: - --node-labels=mylabel=helloworld--==MYBOUNDARY==--
配置容器运行时系统
您可以使用 Amazon Batch CONTAINER_RUNTIME环境变量在托管节点上配置容器运行时。以下示例将容器运行时系统设置为“bootstrap.sh运行时containerd”。有关更多信息,请参阅Kubernetes文档中的containerd
如果您使用的是经过优化的EKS_AL2023或 EKS_AL2023_NVIDIA AMI,则无需指定容器运行时,因为仅支持 c ontainerd。
注意
CONTAINER_RUNTIME环境变量等同于bootstrap.sh的--container-runtime选项。有关更多信息,请参阅Kubernetes文档中的Options
MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" --==MYBOUNDARY== Content-Type: text/x-shellscript; charset="us-ascii" #!/bin/bash mkdir -p /etc/aws-batch echo CONTAINER_RUNTIME=containerd >> /etc/aws-batch/batch.config --==MYBOUNDARY==--
挂载 Amazon EFS 卷
可以使用启动模板将卷装载到节点上。在以下示例中,使用了cloud-configpackages和runcmd设置。有关更多信息,请参阅cloud-init文档中的云配置示例
MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" --==MYBOUNDARY== Content-Type: text/cloud-config; charset="us-ascii" packages: - amazon-efs-utils runcmd: - file_system_id_01=fs-abcdef123 - efs_directory=/mnt/efs - mkdir -p ${efs_directory} - echo "${file_system_id_01}:/ ${efs_directory} efs _netdev,noresvport,tls,iam 0 0" >> /etc/fstab - mount -t efs -o tls ${file_system_id_01}:/ ${efs_directory} --==MYBOUNDARY==--
要在作业中使用此卷,必须将其添加到 eksPro perties 参数中。RegisterJobDefinition以下示例是作业定义的一大部分。
{ "jobDefinitionName": "MyJobOnEks_EFS", "type": "container", "eksProperties": { "podProperties": { "containers": [ { "image": "public.ecr.aws/amazonlinux/amazonlinux:2", "command": ["ls", "-la", "/efs"], "resources": { "limits": { "cpu": "1", "memory": "1024Mi" } }, "volumeMounts": [ { "name": "efs-volume", "mountPath": "/efs" } ] } ], "volumes": [ { "name": "efs-volume", "hostPath": { "path": "/mnt/efs" } } ] } } }
在节点中,Amazon EFS 卷装载在/mnt/efs目录中。在 Amazon EKS 作业的容器中,卷装载在 /efs 目录中。
IPv6 支持
Amazon Batch 支持具有 IPv6 地址的 Amazon EKS 集群。无需自定义即可获得 Amazon Batch 支持。但是,在开始之前,我们建议您查看 Amazon EKS 用户指南中为容器和服务分配 IPv6 地址中概述的注意事项和条件。