Nomad 将下载的 S3 文件放在哪里?

Where does Nomad put the downloaded S3 files?

我有以下 Nomad 工作:

job "aws_s3_copy_rev2" {
  datacenters = ["dc1"]
  type = "system"

  group "aws_s3_copy_rev2" {
    count = 1

    task "aws_s3_copy_rev2" {
      driver = "raw_exec"

      artifact {
        source = "s3::https://my-data-files/123/"
      }

      resources {
        cpu    = 500 # 500 MHz
        memory = 256 # 256MB
        network {
          port "http" {}
        }
      }
    }
  }
}

我使用 nomad run aws_s3_copy_rev2.nomad 提交了作业。但是我不知道文件下载到哪里。 Nomad将下载的S3文件放在哪里?

这是我启动 Nomad 代理的配置文件。

# Increase log verbosity
log_level = "DEBUG"

# Setup data dir
data_dir = "/tmp/client1"

# Give the agent a unique name. Defaults to hostname
name = "client1"

# Enable the client
client {
    enabled = true

    # For demo assume we are talking to server1. For production,
    # this should be like "nomad.service.consul:4647" and a system
    # like Consul used for service discovery.
    servers = ["xxx:4647"]
    options {
      "driver.raw_exec.enable" = "1"
    }
}

# Modify our port to avoid a collision with server1
ports {
    http = 5657
}

通常工件存储在您的 Nomad 分配的分配文件夹中,在默认情况下,在 Linux 机器上是 /etc/nomad.d/alloc/<alloc_id>/<task>/local/<your_file.ext>。不确定其他操作系统上的内容。

在这种情况下,您的 data_dir 设置为 /tmp/client1,因此我希望文件位于 /tmp/client1/alloc/<alloc_id>/<task>/local/<your_file.ext>.

之类的地方

重要的是要注意,这些工件是在 Nomad 'client' 运行 分配你的工作时生成的,而不是你开始工作的机器。

此外,您可能需要小心地将 /tmp 文件夹中的 Nomad 数据目录作为根目录,因为它可能会被定期删除,这可能解释了为什么您找不到这些文件。

您可以在游牧环境中将此目录引用为 ${NOMAD_TASK_DIR} 并使用路径访问或执行文件:

artifact {
    source = "s3::https://some-bucket/code/archive-logs.sh"
    destination = "/local/"
  }

  driver = "raw_exec"
  kill_timeout = "120s"

  config {
    command = "/bin/bash"
    args = ["${NOMAD_TASK_DIR}/archive-logs.sh","7"]
  }