nginx - Nomad : raw_exec 安装 nginx
问题描述
我想运行 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
}
}
}
}
解决方案
如果没有工作状态,就很难解决问题所在。
nomad job status raw-exec
会显示你的工作状态。它还将显示作业创建的分配。您可以检查 Nomad 由nomad alloc status YOUR-ALLOC-ID
.
我已经运行了以下 Nomad 作业规范,它在我的 MacBook 上运行良好。我在一个终端窗口中运行 nomad using nomad agent -dev
,然后在另一个终端窗口中创建文件 test.job 并运行它并在 MacBook 上nomad job run test.job
安装软件。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
命令只运行一次。您可以在此处阅读有关工作类型的更多信息。
推荐阅读
- python - 如何在python中生成学生成绩单
- unit-testing - 无法在测试用例中打开捆绑文件
- java - 'com.sun.javafx.scene.control.skin.ComboBoxBaseSkin' 中没有定义有效的构造函数
- python - TypeError:无法将表达式转换为浮点数 - 定积分 sympy
- javascript - 试图让 Jslib 函数与 C# 函数 UNITY 2017 一起使用
- ios - CKOperationGroup 指定顺序和链操作
- google-cloud-platform - 尝试零停机升级,但 Targetpool 将流量引导到正在被拆除的实例
- node.js - Loopback 3 - 如何在 datasources.json 中使用另一种发送电子邮件的方法
- python - 为类元素制作输入列表
- android - 在 Room 数据库中输入数据时,出现错误