Day 6. Hashicorp Nomad: Submit a Job

Hashicorp Nomad: Submit a Job

今天来写最基本的提交工作(Submit a Job)

Submit

提交工作的指令: nomad job run hello-world.nomad
但提交後但你怎麽知道

  • 改了一堆,改了甚麽?
  • 几百行的code有没有漏改或改错?
  • 现有worker node的资源够不够?
  • 能不能让我测试一下?

Dry-run

所以有一个指令可以用来测试: nomad job plan hello-world.nomad
它会告诉你修改了那些地方,如下的例子:
我修改了image的版本,由"nginx:1.19.2" => "nginx:1.21",
dry-run的结果告诉我 All tasks successfully allocated.并显示修改了哪些地方

$ nomad job plan hello-world.nomad
+/- Job: "hello-world"
+/- Task Group: "webfront" (1 create/destroy update)
  +/- Task: "nginx" (forces create/destroy update)
    +/- Config {
      +/- image:            "nginx:1.19.2" => "nginx:1.21"
          port_map[0][web]: "80"
        }

Scheduler dry-run:
- All tasks successfully allocated.

Job Modify Index: 748164
To submit the job with version verification run:

nomad job run -check-index 748164 nginx.nomad

When running the job with the check-index flag, the job will only be run if the
job modify index given matches the server-side version. If the index has
changed, another user has modified the job and the plan's results are
potentially invalid.

check-index

Dry-run 成功後就可以提交工作了?
在团体开发的环境下,直接执行nomad job plan hello-world.nomad, 要怎麽确保执行的是当下的job呢?
可能下一秒别人就修改了job, 所以Nomad在每次dry-run後都会提供一个Job Modify Index,透过index来保证执行的是当下plan job後的的内容。
但如果在submit job之前,有人又做了plan job得到新的index,则会造成旧的index, submit无效。

Job Modify Index: 748164
To submit the job with version verification run:

nomad job run -check-index 748164 nginx.nomad

<<:  铁人赛 Day6 -- 一定要知道的 CSS (三) - Flex 属性的应用

>>:  [30天 Vue学好学满 DAY6] 计算属性(Computed)

Azure 命令工具资源汇整

葛瑞部落格欢迎光顾 线上工具 Azure CloudShell 离线必要工具 Azure CLI C...

【Day04-档案】你知道Excel最大可以开多少笔资料吗?

前一天我们介绍了用来资料处理最基本的pandas套件 那今天我们则是来谈一下不同的档案类型 我们都知...

Day 7 被动搜查(4)-Email 相关、Harvester、Recon-ng

Email 安全 为什麽要收集各个企业的 Email 信箱,透过了解企业公开在外的 Email,可...

食谱搜寻系统MySQL下载+测试

Mysql下载 因为网路上已经有很多下载教学了,icebear也是参考网路上下载的,所以在这里就不多...

立委名单/提案 Open Data / CsvToBean - day23

目标 今天写个时事题,我们来查询立委议案提案 本日重点 立法院 Open Data 如何将 CSV ...