问题描述
我在我的环境中运行了一个 ECS 集群
,它配置了任务、存储库和服务以及自动缩放.
I have an ECS cluster
running in my environment and it is configured with tasks, repositories and services and autoscaling.
我发现了 AWS Batch
服务,当我创建新的 计算环境
时,会向 ECS
服务添加一个新集群.我想知道如何为我现有的集群设置计算环境
?
I am discovering the AWS Batch
service and when I create a new compute environment
a new cluster is being added to the ECS
service. I want to know how to set a compute environment
to my already existing cluster?
推荐答案
据我所知(花了半天时间,研究文档和论坛),这是不可能的.computeEnvironments
的 ecsClusterArn
在计算环境创建后立即分配,不能更改.
Per my knowledge (spent half of day, studying documentation and forums), that's impossible. computeEnvironments
's ecsClusterArn
is assigned immediately after creation of compute environment, and cannot be changed.
有趣的是,批处理以某种方式修改了托管 CE 中新创建的实例的 /etc/ecs/ecs.config
:
Interesting is that Batch somehow modifies /etc/ecs/ecs.config
on newly created instances in managed CE:
...//来自我的 AMI 的配置ECS_CLUSTER=my_cluster_name...//ECS_CLUSTER={此处的环境名称}_Batch_{此处的随机 UUID}ECS_DISABLE_IMAGE_CLEANUP=falseECS_ENGINE_TASK_CLEANUP_WAIT_DURATION=2mECS_IMAGE_CLEANUP_INTERVAL=10mECS_IMAGE_MINIMUM_CLEANUP_AGE=10mECS_NUM_IMAGES_DELETE_PER_CYCLE=5ECS_RESERVED_MEMORY=32ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","awslogs"]
,第一个 ECS_CLUSTER
用第二个擦除.这看起来像是一些预定义的 user-data
,但我也找不到可以更改的地方.
... // config from my AMIECS_CLUSTER=my_cluster_name... //ECS_CLUSTER={ENVIRONMENT NAME HERE}_Batch_{RANDOM UUID HERE}ECS_DISABLE_IMAGE_CLEANUP=falseECS_ENGINE_TASK_CLEANUP_WAIT_DURATION=2mECS_IMAGE_CLEANUP_INTERVAL=10mECS_IMAGE_MINIMUM_CLEANUP_AGE=10mECS_NUM_IMAGES_DELETE_PER_CYCLE=5ECS_RESERVED_MEMORY=32ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","awslogs"]
, and first ECS_CLUSTER
is wiped with second. That looks like some predefined user-data
, but I couldn't find where that can be changed either.
然而,也许你可以用相反的方法实现最初的目标——创建非托管 CE,并循环你想要在那个 CE 中的实例,在 ECS_CLUSTER
中更改 ECS_CLUSTER
code>/etc/ecs/ecs.config 到 $that_autogenerated_CE_arn
,重新启动 ecs-agent
(或相关的 docker,如果那不是 Amazon Linux).现在您的容器属于另一个集群,唯一不同的是集群名称.
However, probably you can achieve original goal with reversed approach -- create unmanaged CE, and loop over instances you want to be in that CE, change ECS_CLUSTER
in /etc/ecs/ecs.config
to $that_autogenerated_CE_arn
, restart ecs-agent
(or relevant docker, if that's not Amazon Linux). Now your containers belong to another cluster, and only difference is in cluster's name.
这篇关于如何在 AWS Batch 中将现有 ECS 集群设置为计算环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!