Introduction to Nomad Pack
This guide will walk you through basic usage of Nomad Pack, a package manager and templating tool for Nomad.
By the end of this guide, you will know what Nomad Pack does, be able to deploy applications to Nomad using Nomad Pack, and discover packs built by the Nomad community.
What is Nomad Pack
Nomad Pack is a templating and packaging tool used with HashiCorp Nomad.
Nomad Pack is used to:
- Easily deploy popular applications to Nomad
- Re-use common patterns across internal applications
- Find and share job specifications with the Nomad community
Nomad Pack can be thought of as a templating and deployment tool like Levant with the ability to pull from remote registries and deploy multiple resources together, like Helm.
Requirements
- A Nomad cluster available
- Nomad cluster address defined in the
NOMAD_ADDR
environment variable.
Note
If Nomad ACLs are enabled, a token with proper permissions must be defined in the NOMAD_TOKEN
environment variable.
Installing Nomad Pack
To use Nomad Pack, clone the repository:
Change directories to the repository and build the executable with make dev
.
Make the executable available as a command by adding it to your PATH:
You can now run nomad-pack
.
Basic Use
To get started, run the registry list
command to see which packs are available to deploy.
The first time you run registry list, Nomad Pack will add a nomad/packs
directory to your desktop user's cache directory—$XDG_CACHE_DIR
on Linux,
~/Library/Caches
on macOS, %AppData%
on Windows, etc. This folder stores
information about cloned registries and their available packs.
During initializing, Nomad Pack downloads a default registry of packs from the Nomad Pack community registry.
To deploy one of these packs, use the run
command. This deploys each job defined in the pack to Nomad.
To deploy the hello_world
pack, you would run the following command:
Each pack defines a set of variables that can be provided by the user. To get information on the pack
and to see which variables can be passed in, run the info
command.
Values for these variables are provided using the --var
flag. Update your pack using
the following command:
Values can also be provided by passing in a variables file with the -f
flag.
To see a list of deployed packs, run the status
command
To see the status of the jobs deployed by a pack, run the status
command with the pack name.
To remove all the resources deployed by a pack, run the destroy
command with the
pack name.
Adding Non-Default Pack Registries
When using Nomad Pack, the default registry for packs is the Nomad Pack Community Registry. Packs from this registry will be made automatically available.
You can add more registries by using the registry add
command. For instance, if you want to add a registry from GitLab with the alias my_packs
, you can run the following command to download the registry and its contents.
To view the packs you can now deploy, run the registry list
command.
You can deploy packs from this registry with the run
command and the alias given
to the registry, in this case my_packs
.
Next steps
In this tutorial you learned what Nomad Pack does, how to deploy applications to Nomad using Nomad Pack, and how to discover packs built by the Nomad community.
Nomad Pack is valuable when used with official and community packs because it allows you to quickly deploy apps using best practices and leverage communal knowledge. However, many users will also want to write their own packs for internal use.
You can convert your existing Nomad job specifications into reusable packs. To learn more about how packs are structured and how to write your own, see the Writing Packs Guide.