当前位置:网站首页>Nomad application layout scheme 07 of hashicopy (submit job)

Nomad application layout scheme 07 of hashicopy (submit job)

2022-06-11 13:19:00 Hua Weiyun

One background

stay Nomad in , The job description and all its requirements are stored in a file called “ Working papers ” In the file of . This job file resides on a local disk , It is strongly recommended that you check the job file into source control .
stay Nomad The general process for submitting jobs in is :

  1. Prepare operation documents according to operation specifications
  2. Use Nomad Server schedules and checks for changes
  3. Submit job files to Nomad The server
  4. ( Optional ) Check the job status and log

Here is a very basic example to get you started .

Two Write a Job file

Nomad Trying to strike a balance between ease and expression in its working specifications .Nomad It also provides Nomad init Command to generate a sample job file . of Nomad More details of the job specification , see also Nomad file .
Here is a sample job file , It first runs a small docker Containers web The server .

job "docs" {  datacenters = ["dc1"]  group "example" {    network {      port "http" {        static = "5678"      }    }    task "server" {      driver = "docker"      config {        image = "hashicorp/http-echo"        ports = ["http"]        args = [          "-listen",          ":5678",          "-text",          "hello world",        ]      }    }  }}

This job file exists in plain text on the local workstation . When you are satisfied with this job file , You will plan and review planning process decisions . Submitting job files to source control is often a best practice , Especially when working in a team .

3、 ... and Plan a Job

After the preparation of operation documents , You may want to preview Nomad Changes made at runtime .nomad job plan Command invokes a drill of the dispatcher , And output which scheduling decisions will be executed .

nomad job plan httpecho.nomad

Please note that , No action was taken . This job is not running . This is a complete exercise , There is no funding .

Four To submit a Job

Suppose the output of the plan looks acceptable , Now ask Nomad Execute the job . This is through nomad job run Command completed . You may choose to provide by plan Command provided modify Indexes , To ensure that no changes have been made to this job between the schedule and now .

Now that you have planned your homework , It may be running , It may not be running . You need to check the allocation status and log , To ensure that the job starts correctly . The next section on checking status details how to check the status of this job .

5、 ... and Update and apply a Job

When updating a job , It is best to always run plan command , And then run run command . for example :

6、 ... and Run one Job

Now? , Assume that the output is normal , perform nomad job run command . Include check-index Parameters ensure that the job does not change between the planning phase and the running phase .

About advanced job update policy ( Such as Canary construction and green deployment ) For more details , Refer to the documentation for the job update policy .

Reference link

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111312171348.html