【问题标题】:Where does Nomad put the downloaded S3 files?Nomad 将下载的 S3 文件放在哪里?
【发布时间】:2020-02-26 07:27:36
【问题描述】:

我有以下 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
}

【问题讨论】:

    标签: amazon-s3 nomad


    【解决方案1】:

    通常工件存储在 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“客户端”上生成的,而不是在您开始作业的机器上生成的。

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

    【讨论】:

    • 我在/etc/ 中找不到nomad.d 目录。
    • 根据您提供的配置更新了我的答案。
    【解决方案2】:

    您可以在 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"]
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      • 1970-01-01
      • 2020-06-12
      • 1970-01-01
      • 2018-06-27
      相关资源
      最近更新 更多