【问题标题】:Nomad : raw_exec install nginxNomad : raw_exec 安装 nginx
【发布时间】:2020-07-01 07:16:27
【问题描述】:

我想运行 raw_exec 来安装一个 nginx ,这可能吗?或者如何仅由 raw_exec 完成。因为这段代码不会启动/运行。

job "raw-exec" {
  datacenters = ["dc1"]
  type        = "service"

  group "exec" {
    count = 1

    update {
       max_parallel      = 1
       min_healthy_time  = "10s"
       healthy_deadline  = "5m"
       progress_deadline = "10m"
       auto_revert       = true
     }

    task "raw-exec-test" {
      driver = "raw_exec"

      config {
        command = "/bin/apt"
        args = ["-y", "install", "nginx.service"]
      }

      resources {
        cpu    = 100
        memory = 125
      }

    }
  }
}

【问题讨论】:

  • 运行规范时的输出是什么?请注意,raw_exec 驱动程序默认未启用。它已在 Nomad 配置中明确启用。

标签: nginx driver ubuntu-18.04 nomad


【解决方案1】:

如果没有工作状态,就很难解决问题所在。 nomad job status raw-exec 将显示您的工作状态。它还将显示作业创建的分配。 您可以检查 Nomad 由 nomad alloc status YOUR-ALLOC-ID 创建的分配(作业中的一组任务应该在特定节点上运行)有什么问题。

我已经运行了以下 Nomad 作业规范,它在我的 MacBook 上运行良好。 我在一个终端窗口中使用nomad agent -dev 运行nomad,然后在另一个终端窗口中创建文件test.job 并运行nomad job run test.job,它在MacBook 上安装了htop 软件。

job "raw-exec" {
  datacenters = ["dc1"]
  type        = "batch"

  group "exec" {
    count = 1

    task "raw-exec-test" {
      driver = "raw_exec"

      config {
        command = "brew"
        args = ["install", "htop"]
      }

      resources {
        cpu    = 100
        memory = 125
      }
    }
  }
}

请注意,我已将工作 type 从服务更改为批处理。批处理作业设计为运行一次,而服务应始终启动并运行。我想您希望您的 apt install -y nginx 命令只运行一次。你可以read more about job types here

【讨论】:

    猜你喜欢
    • 2021-02-07
    • 2021-10-20
    • 1970-01-01
    • 2019-05-19
    • 2015-09-08
    • 2018-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多