Install Nomad
Nomad is available as a pre-compiled binary or as a package for several operating systems. You can also build Nomad from source.
If you are interested in trialing Nomad without installing it locally, see the Quickstart for options to get started with Nomad.
Install the required packages.
$ sudo apt-get update && \
sudo apt-get install wget gpg coreutils
Add the HashiCorp GPG key.
$ wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
Add the official HashiCorp Linux repository.
$ echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Update and install.
$ sudo apt-get update && sudo apt-get install nomad
Post-installation steps
These steps are optional but can be helpful for running Nomad and to take advantage of additional Nomad functionalities.
You need to run client agents as root (or with sudo
) so that cpuset accounting and network namespaces work correctly.
Add the Nomad binary to your system path
Permanently add a new location to your path by editing your shell's settings file, which is usually called something like ~/.bashrc
, where the part of the filename after the .
and before rc
is the name of your shell. In that file you should see a line that starts with export PATH=
, followed by a colon-separated list of locations. Add the location of the Nomad binary to that list and save the file. Then reload your shell's configuration with the command source ~/.bashrc
, replacing bash
with the name of your shell.
Install CNI reference plugins
Nomad uses CNI plugins to configure network namespaces when using the bridge
network mode. You must install the CNI plugins on all Linux Nomad client nodes that use network namespaces. Refer to the CNI Plugins Overview guide for details on individual plugins.
The following determines your operating system architecture, downloads the 1.5.1 release, and extracts the CNI plugin binaries into the /opt/cni/bin
directory. Update the CNI_PLUGIN_VERSION
value if you want to use a different release version.
$ export ARCH_CNI=$( [ $(uname -m) = aarch64 ] && echo arm64 || echo amd64)
$ export CNI_PLUGIN_VERSION=v1.5.1
$ curl -L -o cni-plugins.tgz "https://github.com/containernetworking/plugins/releases/download/${CNI_PLUGIN_VERSION}/cni-plugins-linux-${ARCH_CNI}-${CNI_PLUGIN_VERSION}".tgz && \
sudo mkdir -p /opt/cni/bin && \
sudo tar -C /opt/cni/bin -xzf cni-plugins.tgz
Install consul-cni plugin
If you use the transparent_proxy
block for Consul Service Mesh, then you must install the
consul-cni
plugin on each client node to redirect inbound and outbound traffic for services to the Envoy proxy.
Install the CNI plugins before you install the Consul CNI plugin. The following commands assume that you have installed the CNI plugins.
Install the consul-cni
plugin on each client node.
$ sudo apt-get install -y consul-cni
Configure bridge network to route traffic through iptables
Nomad's task group networks and Consul Connect integration use bridge networking and iptables to send traffic between containers. The Linux kernel bridge module has three "tunables" that control whether iptables process traffic crossing the bridge. Some operating systems (RedHat, CentOS, and Fedora in particular) configure these tunables to optimize for VM workloads where iptables rules might not be correctly configured for guest traffic.
Ensure your Linux operating system distribution has been configured to allow iptables to route container traffic through the bridge network. Set these tunables to allow iptables processing for the bridge network.
$ echo 1 > /proc/sys/net/bridge/bridge-nf-call-arptables
$ echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables
$ echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
To preserve these settings on startup of a client node, add a file including the following to /etc/sysctl.d/
or remove the file your Linux distribution puts in that directory.
/etc/sysctl.d/bridge.conf
net.bridge.bridge-nf-call-arptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
Verify cgroup controllers
On Linux, Nomad uses cgroups to control access to resources like CPU and
memory. Nomad supports both cgroups v2 and the legacy cgroups
v1. When Nomad clients start, they determine the available cgroup controllers and include the attribute os.cgroups.version
in their fingerprint.
Nomad can only use cgroups to control resources if all the required controllers are available. If one or more required cgroups are not available, Nomad disables resource controls that require cgroups entirely. You most often see missing controllers on platforms used outside of datacenters, such as Raspberry Pi or similar hobbyist computers.
On cgroups v2, you can verify that you have all required controllers.
$ cat /sys/fs/cgroup/cgroup.controllers
cpuset cpu io memory pids
On legacy cgroups v1, look for this same list of required controllers as directories under the directory /sys/fs/cgroup
.
To enable missing cgroups, add the appropriate boot command line arguments. For
example, to enable the cpuset
cgroup, add cgroup_cpuset=1 cgroup_enable=cpuset
. Add these arguments wherever specified by your bootloader.
Refer to the cgroup controller requirements for more details.
Verify the Installation
To verify Nomad was installed correctly, try the nomad
command.
$ nomad
You should see help output, similar to the following.
Usage: nomad [-version] [-help] [-autocomplete-(un)install] <command> [args]
Common commands:
run Run a new job or update an existing job
stop Stop a running job
status Display the status output for a resource
alloc Interact with allocations
job Interact with jobs
node Interact with nodes
agent Runs a Nomad agent
Other commands:
acl Interact with ACL policies and tokens
agent-info Display status information about the local agent
config Interact with configurations
deployment Interact with deployments
eval Interact with evaluations
exec Execute commands in task
fmt Rewrites Nomad config and job files to canonical format
license Interact with Nomad Enterprise License
login Login to Nomad using an auth method
monitor Stream logs from a Nomad agent
namespace Interact with namespaces
operator Provides cluster-level tools for Nomad operators
plugin Inspect plugins
quota Interact with quotas
recommendation Interact with the Nomad recommendation endpoint
scaling Interact with the Nomad scaling endpoint
sentinel Interact with Sentinel policies
server Interact with servers
service Interact with registered services
system Interact with the system API
tls Generate Self Signed TLS Certificates for Nomad
ui Open the Nomad Web UI
var Interact with variables
version Prints the Nomad version
volume Interact with volumes
Compiling from Source
To compile from source, you will need Go installed at the
version described by the .go-version file. You should properly
configure your Go environment, including setting a GOPATH
environment variable
and ensuring GOPATH/bin
is within your PATH
. A copy of
git
is also needed in your PATH
.
Clone the Nomad repository from GitHub into your
GOPATH
:$ mkdir -p $GOPATH/src/github.com/hashicorp && cd $_ $ git clone https://github.com/hashicorp/nomad.git $ cd nomad
Bootstrap the project. This will download and compile libraries and tools needed to compile Nomad:
$ make bootstrap
Build Nomad for your current system and put the binary in
./bin/
(relative to the git checkout). Themake dev
target is just a shortcut that buildsnomad
for only your local build environment (no cross-compiled targets).$ make dev