open-nomad/website/source/intro/getting-started/jobs.html.md

347 lines
12 KiB
Markdown
Raw Normal View History

2015-09-22 22:57:12 +00:00
---
layout: "intro"
page_title: "Jobs"
sidebar_current: "getting-started-jobs"
description: |-
2015-09-22 23:18:26 +00:00
Learn how to submit, modify and stop jobs in Nomad.
2015-09-22 22:57:12 +00:00
---
# Jobs
2015-09-22 23:18:26 +00:00
Jobs are the primary configuration that users interact with when using
2015-09-23 01:19:00 +00:00
Nomad. A job is a declarative specification of tasks that Nomad should run.
2015-09-22 23:18:26 +00:00
Jobs have a globally unique name, one or many task groups, which are themselves
collections of one or many tasks.
2015-09-22 22:57:12 +00:00
The format of the jobs is documented in the [job specification][jobspec]. They
can either be specified in [HashiCorp Configuration Language][hcl] or JSON,
2015-09-22 23:18:26 +00:00
however we recommend only using JSON when the configuration is generated by a machine.
2015-09-22 22:57:12 +00:00
2015-09-23 01:10:46 +00:00
## Running a Job
2018-03-22 20:39:18 +00:00
To get started, we will use the [`job init` command](/docs/commands/job/init.html) which
2015-10-10 19:27:09 +00:00
generates a skeleton job file:
2015-09-22 22:57:12 +00:00
2017-11-01 18:15:44 +00:00
```text
2018-03-22 20:39:18 +00:00
$ nomad job init
2015-09-23 01:10:46 +00:00
Example job file written to example.nomad
```
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
You can view the contents of this file by running `cat example.nomad`. In this
example job file, we have declared a single task 'redis' which is using
2015-09-23 01:10:46 +00:00
the Docker driver to run the task. The primary way you interact with Nomad
2018-03-22 20:39:18 +00:00
is with the [`job run` command](/docs/commands/job/run.html). The `run` command takes
2015-09-23 01:10:46 +00:00
a job file and registers it with Nomad. This is used both to register new
jobs and to update existing jobs.
We can register our example job now:
2017-11-01 18:15:44 +00:00
```text
2018-03-22 20:39:18 +00:00
$ nomad job run example.nomad
2017-11-01 18:15:44 +00:00
==> Monitoring evaluation "13ebb66d"
2015-09-23 01:10:46 +00:00
Evaluation triggered by job "example"
2017-11-01 18:15:44 +00:00
Allocation "883269bf" created: node "e42d6f19", group "cache"
Evaluation within deployment: "b0a84e74"
2015-09-23 01:10:46 +00:00
Evaluation status changed: "pending" -> "complete"
2017-11-01 18:15:44 +00:00
==> Evaluation "13ebb66d" finished with status "complete"
2015-09-23 01:10:46 +00:00
```
Anytime a job is updated, Nomad creates an evaluation to determine what
actions need to take place. In this case, because this is a new job, Nomad has
determined that an allocation should be created and has scheduled it on our
local agent.
To inspect the status of our job we use the [`status` command](/docs/commands/status.html):
2017-11-01 18:15:44 +00:00
```text
2015-09-23 01:10:46 +00:00
$ nomad status example
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
ID = example
Name = example
2017-11-01 18:15:44 +00:00
Submit Date = 10/31/17 22:58:40 UTC
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Type = service
Priority = 50
Datacenters = dc1
Status = running
Periodic = false
Parameterized = false
2015-09-23 01:10:46 +00:00
Summary
Task Group Queued Starting Running Failed Complete Lost
cache 0 0 1 0 0 0
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Latest Deployment
2017-11-01 18:15:44 +00:00
ID = b0a84e74
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Status = successful
Description = Deployment completed successfully
Deployed
Task Group Desired Placed Healthy Unhealthy
cache 1 1 1 0
2016-06-25 02:15:55 +00:00
Allocations
ID Node ID Task Group Version Desired Status Created Modified
8ba85cef 171a583b cache 0 run running 5m ago 5m ago
2015-09-23 01:10:46 +00:00
```
2016-06-25 02:15:55 +00:00
Here we can see that the result of our evaluation was the creation of an
allocation that is now running on the local node.
2015-09-23 01:10:46 +00:00
An allocation represents an instance of Task Group placed on a node. To inspect
2018-03-22 20:39:18 +00:00
an allocation we use the [`alloc status` command](/docs/commands/alloc/status.html):
2017-11-01 18:15:44 +00:00
```text
$ nomad alloc status 8ba85cef
ID = 8ba85cef
2017-11-01 18:15:44 +00:00
Eval ID = 13ebb66d
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Name = example.cache[0]
2017-11-01 18:15:44 +00:00
Node ID = e42d6f19
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Job ID = example
Job Version = 0
Client Status = running
Client Description = <none>
Desired Status = run
Desired Description = <none>
Created = 5m ago
Modified = 5m ago
Deployment ID = fa882a5b
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Deployment Health = healthy
2016-06-25 02:15:55 +00:00
Task "redis" is "running"
Task Resources
CPU Memory Disk Addresses
8/500 MHz 6.3 MiB/256 MiB 300 MiB db: 127.0.0.1:22672
2017-11-01 18:15:44 +00:00
Task Events:
Started At = 10/31/17 22:58:49 UTC
Finished At = N/A
Total Restarts = 0
Last Restart = N/A
2016-06-25 02:15:55 +00:00
Recent Events:
2017-11-01 18:15:44 +00:00
Time Type Description
10/31/17 22:58:49 UTC Started Task started by client
10/31/17 22:58:40 UTC Driver Downloading image redis:3.2
10/31/17 22:58:40 UTC Task Setup Building Task Directory
10/31/17 22:58:40 UTC Received Task received by client
```
2016-06-25 02:15:55 +00:00
We can see that Nomad reports the state of the allocation as well as its
current resource usage. By supplying the `-stats` flag, more detailed resource
usage statistics will be reported.
To see the logs of a task, we can use the [`logs` command](/docs/commands/alloc/logs.html):
2017-11-01 18:15:44 +00:00
```text
2018-05-21 22:54:26 +00:00
$ nomad alloc logs 8ba85cef redis
2016-06-25 02:15:55 +00:00
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.1 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
...
```
2015-09-23 01:10:46 +00:00
## Modifying a Job
The definition of a job is not static, and is meant to be updated over time.
You may update a job to change the docker container, to update the application version,
or to change the count of a task group to scale with load.
2015-09-23 01:10:46 +00:00
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
For now, edit the `example.nomad` file to update the count and set it to 3:
2015-09-23 01:10:46 +00:00
```
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
# The "count" parameter specifies the number of the task groups that should
# be running under this group. This value must be non-negative and defaults
# to 1.
2015-09-23 01:10:46 +00:00
count = 3
```
2018-03-22 20:39:18 +00:00
Once you have finished modifying the job specification, use the [`job plan`
command](/docs/commands/job/plan.html) to invoke a dry-run of the scheduler to see
what would happen if you ran the updated job:
2015-09-23 01:10:46 +00:00
2017-11-01 18:15:44 +00:00
```text
2018-03-22 20:39:18 +00:00
$ nomad job plan example.nomad
2016-06-25 02:15:55 +00:00
+/- Job: "example"
+/- Task Group: "cache" (2 create, 1 in-place update)
+/- Count: "1" => "3" (forces create)
Task: "redis"
Scheduler dry-run:
- All tasks successfully allocated.
2017-11-01 18:15:44 +00:00
Job Modify Index: 7
2016-06-25 02:15:55 +00:00
To submit the job with version verification run:
2018-03-22 20:39:18 +00:00
nomad job run -check-index 7 example.nomad
2016-06-25 02:15:55 +00:00
When running the job with the check-index flag, the job will only be run if the
server side version matches the job modify index returned. If the index has
2016-06-25 02:15:55 +00:00
changed, another user has modified the job and the plan's results are
potentially invalid.
```
We can see that the scheduler detected the change in count and informs us that
it will cause 2 new instances to be created. The in-place update that will
2017-11-01 18:15:44 +00:00
occur is to push the updated job specification to the existing allocation and
will not cause any service interruption. We can then run the job with the run
command the `plan` emitted.
2016-06-25 02:15:55 +00:00
By running with the `-check-index` flag, Nomad checks that the job has not
been modified since the plan was run. This is useful if multiple people are
interacting with the job at the same time to ensure the job hasn't changed
before you apply your modifications.
```
2018-03-22 20:39:18 +00:00
$ nomad job run -check-index 7 example.nomad
2017-11-01 18:15:44 +00:00
==> Monitoring evaluation "93d16471"
2015-09-23 01:10:46 +00:00
Evaluation triggered by job "example"
2017-11-01 18:15:44 +00:00
Evaluation within deployment: "0d06e1b6"
Allocation "3249e320" created: node "e42d6f19", group "cache"
Allocation "453b210f" created: node "e42d6f19", group "cache"
Allocation "883269bf" modified: node "e42d6f19", group "cache"
2015-09-23 01:10:46 +00:00
Evaluation status changed: "pending" -> "complete"
2017-11-01 18:15:44 +00:00
==> Evaluation "93d16471" finished with status "complete"
2015-09-23 01:10:46 +00:00
```
Because we set the count of the task group to three, Nomad created two
additional allocations to get to the desired state. It is idempotent to
run the same job specification again and no new allocations will be created.
2015-10-10 20:06:00 +00:00
Now, let's try to do an application update. In this case, we will simply change
2015-09-23 01:10:46 +00:00
the version of redis we want to run. Edit the `example.nomad` file and change
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
the Docker image from "redis:3.2" to "redis:4.0":
2015-09-23 01:10:46 +00:00
```
# Configure Docker driver with the image
config {
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
image = "redis:4.0"
2015-09-22 23:18:26 +00:00
}
2015-09-23 01:10:46 +00:00
```
2016-06-25 02:15:55 +00:00
We can run `plan` again to see what will happen if we submit this change:
2017-11-01 18:15:44 +00:00
```text
2016-06-25 02:15:55 +00:00
+/- Job: "example"
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
+/- Task Group: "cache" (1 create/destroy update, 2 ignore)
2016-06-25 02:15:55 +00:00
+/- Task: "redis" (forces create/destroy update)
+/- Config {
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
+/- image: "redis:3.2" => "redis:4.0"
2016-06-25 02:15:55 +00:00
port_map[0][db]: "6379"
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
}
2016-06-25 02:15:55 +00:00
Scheduler dry-run:
- All tasks successfully allocated.
2017-11-01 18:15:44 +00:00
Job Modify Index: 1127
2016-06-25 02:15:55 +00:00
To submit the job with version verification run:
2018-03-22 20:39:18 +00:00
nomad job run -check-index 1127 example.nomad
2016-06-25 02:15:55 +00:00
When running the job with the check-index flag, the job will only be run if the
server side version matches the job modify index returned. If the index has
2016-06-25 02:15:55 +00:00
changed, another user has modified the job and the plan's results are
potentially invalid.
```
The plan output shows us that one allocation will be updated and that the other
two will be ignored. This is due to the `max_parallel` setting in the `update`
stanza, which is set to 1 to instruct Nomad to perform only a single change at
2017-08-18 23:18:20 +00:00
a time.
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Once ready, use `run` to push the updated specification:
2015-09-22 22:57:12 +00:00
2017-11-01 18:15:44 +00:00
```text
2018-03-22 20:39:18 +00:00
$ nomad job run example.nomad
2017-11-01 18:15:44 +00:00
==> Monitoring evaluation "293b313a"
2016-02-06 00:28:20 +00:00
Evaluation triggered by job "example"
2017-11-01 18:15:44 +00:00
Evaluation within deployment: "f4047b3a"
Allocation "27bd4a41" created: node "e42d6f19", group "cache"
2016-02-06 00:28:20 +00:00
Evaluation status changed: "pending" -> "complete"
2017-11-01 18:15:44 +00:00
==> Evaluation "293b313a" finished with status "complete"
2015-09-23 01:10:46 +00:00
```
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
After running, the rolling upgrade can be followed by running `nomad status` and
watching the deployed count.
We can see that Nomad handled the update in three phases, only updating a single
allocation in each phase and waiting for it to be healthy for `min_healthy_time`
of 10 seconds before moving on to the next. The update strategy can be
configured, but rolling updates makes it easy to upgrade an application at large
scale.
2015-09-23 01:10:46 +00:00
## Stopping a Job
So far we've created, run and modified a job. The final step in a job lifecycle
2018-03-22 20:39:18 +00:00
is stopping the job. This is done with the [`job stop` command](/docs/commands/job/stop.html):
2015-09-23 01:10:46 +00:00
2017-11-01 18:15:44 +00:00
```text
2018-03-22 20:39:18 +00:00
$ nomad job stop example
2017-11-01 18:15:44 +00:00
==> Monitoring evaluation "6d4cd6ca"
2015-09-23 01:10:46 +00:00
Evaluation triggered by job "example"
2017-11-01 18:15:44 +00:00
Evaluation within deployment: "f4047b3a"
2015-09-23 01:10:46 +00:00
Evaluation status changed: "pending" -> "complete"
2017-11-01 18:15:44 +00:00
==> Evaluation "6d4cd6ca" finished with status "complete"
2015-09-23 01:10:46 +00:00
```
When we stop a job, it creates an evaluation which is used to stop all
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
the existing allocations. If we now query the job status, we can see it is
now marked as `dead (stopped)`, indicating that the job has been stopped and
Nomad is no longer running it:
2015-09-23 01:10:46 +00:00
2017-11-01 18:15:44 +00:00
```text
2015-09-23 01:10:46 +00:00
$ nomad status example
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
ID = example
Name = example
2017-11-01 18:15:44 +00:00
Submit Date = 11/01/17 17:30:40 UTC
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Type = service
Priority = 50
Datacenters = dc1
Status = dead (stopped)
Periodic = false
Parameterized = false
Summary
Task Group Queued Starting Running Failed Complete Lost
2017-11-01 18:15:44 +00:00
cache 0 0 0 0 6 0
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Latest Deployment
2017-11-01 18:15:44 +00:00
ID = f4047b3a
Getting Started guide updates for 0.6.0 (#2909) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * further information in job status added in 0.6 * update output when changing redis version * make new date consistent in * add Latest Deployment and Deployed sections to output * small changes in status values so that things the user should see as thesame, are the same in the example (e.g. Node ID should be the same in all places we list it in the example) * Add new commands for 0.6 * update version in documnetation for 0.6 * more information in example.nomad * 0.6 additional information for viewing status of a job * 0.6 status for alloc-status * changes with 0.6 in modifying a job * status is healthy when consul is running * further information in job status added in 0.6 * evaluation status for deployment in 0.6 * updating client demo config to match website * update output of status for cluster * update output when changing redis version * update terminal output of adding more redis instances. * small update so id numbers are consistent in example * update ouput for , also stitch up ids from previous lines to match * add to output when starting server and clients * add to output * remove text showing large parts of example.nomad file * Small fixes to stopping and updating a job
2017-07-26 21:24:50 +00:00
Status = successful
Description = Deployment completed successfully
Deployed
Task Group Desired Placed Healthy Unhealthy
cache 3 3 3 0
Allocations
ID Node ID Task Group Version Desired Status Created Modified
8ace140d 2cfe061e cache 2 stop complete 5m ago 5m ago
8af5330a 2cfe061e cache 2 stop complete 6m ago 6m ago
df50c3ae 2cfe061e cache 2 stop complete 6m ago 6m ago
2015-09-23 01:10:46 +00:00
```
If we wanted to start the job again, we could simply `run` it again.
2015-09-22 22:57:12 +00:00
## Next Steps
2015-09-23 01:10:46 +00:00
Users of Nomad primarily interact with jobs, and we've now seen
how to create and scale our job, perform an application update,
2015-09-23 01:34:30 +00:00
and do a job tear down. Next we will add another Nomad
client to [create our first cluster](cluster.html)
2015-09-22 23:18:26 +00:00
[jobspec]: /docs/job-specification/index.html "Nomad Job Specification"
[hcl]: https://github.com/hashicorp/hcl "HashiCorp Configuration Language"