Now that you have reached the end of the Get Started collection, it's time to stop everything and clean up the tutorial artifacts. Start by stopping the job.
»Stop the job
So far you’ve created, run, and modified a job. You also explored Nomad's web interface. The final step in a job's lifecycle is stopping it. Select the way that you would like to stop the example job.
Stop the job using the
nomad job stop command.
$ nomad job stop example
==> Monitoring evaluation "f35b553d" Evaluation triggered by job "example" Evaluation within deployment: "ee36aca3" Evaluation status changed: "pending" -> "complete" ==> Evaluation "f35b553d" finished with status "complete"
When you stop a job, it creates an evaluation which is used to stop all the
existing allocations. If you now query the job status, you can see it is now
dead (stopped), indicating that the job has been stopped and Nomad
is no longer running it:
$ nomad job status example
ID = example Name = example Submit Date = 2021-02-08T18:28:24Z Type = service Priority = 50 Datacenters = dc1 Namespace = default Status = dead (stopped) Periodic = false Parameterized = false Summary Task Group Queued Starting Running Failed Complete Lost cache 0 0 0 0 6 0 Latest Deployment ID = ee36aca3 Status = successful Description = Deployment completed successfully Deployed Task Group Desired Placed Healthy Unhealthy Progress Deadline cache 3 3 3 0 2021-02-08T18:39:06Z Allocations ID Node ID Task Group Version Desired Status Created Modified f00b3db7 3825e530 cache 2 stop complete 3m11s ago 14s ago 4a7481b4 3825e530 cache 2 stop complete 3m24s ago 14s ago 6290708b 3825e530 cache 2 stop complete 3m43s ago 14s ago 5765545f 3825e530 cache 1 stop complete 16m3s ago 3m11s ago 95a4f6b7 3825e530 cache 1 stop complete 16m3s ago 3m23s ago 635a981a 3825e530 cache 1 stop complete 18m53s ago 3m42s ago
If you wanted to start the job again, you can use the
nomad job run command
to run it again.
»Stop the dev agent
In the shell session running your dev agent, use
Ctrl-C, the interrupt signal,
to stop the agent.
After interrupting the agent, the logs show the cluster shutting down:
^C==> Caught signal: interrupt [INFO] agent: requesting shutdown [INFO] client: shutting down [INFO] client.plugin: shutting down plugin manager: plugin-type=device [INFO] client.plugin: plugin manager finished: plugin-type=device [INFO] client.plugin: shutting down plugin manager: plugin-type=driver [INFO] client.plugin: plugin manager finished: plugin-type=driver [INFO] nomad: shutting down server [WARN] nomad: serf: Shutdown without a Leave [INFO] agent: shutdown complete
By gracefully leaving, Nomad servers notify their peers they intend to leave. When a server leaves, replication to that server stops. Nomad clients update their status to prevent further tasks from being scheduled and to start migrating any tasks that are already assigned.
»Halt the VM
If you are using the Vagrant environment to run Nomad, exit any shell sessions
that you made to the virtual machine. Use the
vagrant halt command to stop the
$ vagrant halt
At this point, you can start the VM again without having to provision it.
»De-provision the VM
If you don't anticipate using the training VM for a while, and don't mind the
time necessary to provision it, you can deprovision the VM. From the folder that
contains the Vagrantfile you downloaded, use the
vagrant destroy command to
deprovision the environment your created. The command verifies that you intend
to perform this activity; enter
Y to confirm that you do.
$ vagrant destroy
default: Are you sure you want to destroy the 'default' VM? [y/N] y ==> default: Forcing shutdown of VM... ==> default: Destroying VM and associated drives...
De-provisioning the environment deletes the VM that is created based on the base box.
»Delete the Vagrantfile
If you don't intend to use the Vagrant environment again, you can remove the
Vagrantfile and the
nomad-demo folder that you created in the Installation
»Remove the base box
If you don't intend to use the Vagrant environment ever again, you can also
delete the downloaded Vagrant base box used to create the VM by running the
vagrant box remove command. Don't worry, if you decide to use the environment
again later, Vagrant re-downloads the base box when you need it.
$ vagrant box remove bento/ubuntu-18.04
Removing box 'bento/ubuntu-18.04' (v202008.16.0) with provider 'virtualbox'...
At this point, you have removed all of the parts that are added by starting up the Vagrantfile.
That concludes the Get Started tutorial collection for Nomad. Hopefully you are excited about the possibilities of Nomad and ready to put this knowledge to use to improve your environment.
You've covered the basics of all the core features of Nomad in this guide. Consider exploring the following resources as next steps.
There are many more Learn Tutorials to provide best practices and guidance for using and operating Nomad in a real-world production setting. Some places you might like to start are:
For developers, consider Deploy and Manage Nomad Jobs, which contains more information about how to run your own workload in Nomad.
For operations, Operating Nomad Clusters, which describes Nomad features that operators need to understand to build and maintain Nomad clusters.
Some of the tutorials require a Nomad cluster. You can create a cluster in AWS using this example Terraform configuration.