运行在ECS容器中的进程是否可以在运行时确定其服务名称?

时间:2018-06-07 18:25:45

标签: amazon-ecs

我们正在考虑一个基础架构,其中在ECS容器内运行的进程将唯一标识符传递给REST API,以便检索其启动配置。

如果我们为UID使用环境变量,则意味着每次启动服务时都会创建一个新的任务定义,只是为容器提供其标识符。

- ECS service "myservice123"  (some unique name)
  - task definition **custom version required for each launch of the service, to provide the UID env var
    - container with environment var UID="xyz"
      - process retrieves env var UID
      - process passes UID value "xyz" to REST API

根据定义,服务名称必须是唯一的,因此我们考虑将UID包含为后缀。这意味着在容器内运行的进程需要能够在运行时确定其服务名称。这可能吗?

- ECS service "myservice-xyz"  (the UID is part of the service name)
  - task definition **standard, only one version required
    - container with no environment vars
      - process determines its service name and extracts the UID suffix "xyz"
      - process passes UID value "xyz" to REST API

在ECS容器内运行的进程是否可以确定其服务名称?

0 个答案:

没有答案