How to configure hostname in ECS Fargate task definition

前端 未结 4 1792
攒了一身酷
攒了一身酷 2021-02-08 21:42

We are migrating from ECS to Fargate. In ECS, we could set the hostname in the task definition like this:
\"hostname\": \"%HOST_NAME%\"

It fails to create with the e

4条回答
  •  眼角桃花
    2021-02-08 22:16

    Let me share a tip that I have applied for setting up the Avro Schema Registry. It could be helpful in answering this question. Schema Registry requires setting the SCHEMA_REGISTRY_HOST_NAME environment variable. With AWS Fargate and awsvpc networking mode there is no way to explicitly set the host name property inside the task definition, as was already pointed out in this thread. For horizontal scaling you need multiple registry instances each having its own SCHEMA_REGISTRY_HOST_NAME value. I had overridden the Command property in a task definition in the following manner (the HOSTNAME is provided by Docker and under awsvpc regime it reliably reflects the host name):

    sh,-c,export SCHEMA_REGISTRY_HOST_NAME=$HOSTNAME;/etc/confluent/docker/run
    

    The downside of this approach is that you now depend on the implementation detail of the image; in this case the original CMD statement from the Dockerfile. This is why it is always important to use a specific version tag with an image name instead of relying on the latest tag.

    P.S. As a reference, here is my original comment on Issues 1126 for Schema Registry.

提交回复
热议问题