Create a cluster
Nomad is a flexible scheduler that can run on your local machine as a single node cluster or as a multi-node cluster on virtualized or physical infrastructure.
In this tutorial, you will create a cluster locally on your machine or on one of the major cloud providers, verify connectivity to the cluster, and interact with Nomad via the UI.
Prerequisites
- Docker Desktop installed locally
Nomad supports many task drivers but the example application in this tutorial uses Docker. Docker Desktop provides the Docker engine, the CLI client, and a graphical interface. Other third-party options are available for running Docker on your machine but we recommend Docker Desktop for the simplicity and ease of use.
Nomad uses a socket file to communicate with Docker and by default, this file is /var/run/docker.sock
on Linux, Mac, and other Unix platforms, and /./pipe/docker_engine
on Windows. Docker Desktop creates a symlink to this socket during installation.
If the Nomad client fails to detect the Docker driver with the error Constraint "missing drivers": 1 nodes excluded by filter
, the issue may be this missing symlink. Additional information about this symlink for Mac and Windows is available.
Clone the code repository
The example repository includes Terraform configurations for starting a cluster on the cloud as well as the jobspec files for the example application.
Clone the code repository.
Navigate to the repository folder.
Check out the v1.1
tag of the repository as a local branch named nomad-getting-started
.
Create the cluster
Start a Nomad cluster. You will use the Nomad CLI to access your cluster regardless of its location. Select where you want to create and run your cluster.
Open your terminal and start the development agent. This creates a Nomad cluster of one node that acts as both the server and client.
Warning
This tutorial uses the network interface attached to the default route on your machine and as a result, workloads will be accessible to other machines on the same network. This is for development and illustration purposes. We recommend using a firewall for production environments or when connected to public networks to limit unauthorized workload access.
The -bind
flag set to 0.0.0.0
instructs Nomad to listen on all network interfaces present on the machine. The -network-interface
flag instructs Nomad to use a network interface other than the default loopback interface (localhost
). In this example, Nomad automatically gets the network interface attached to the default route on the machine with the GetDefaultInterfaces
function but you can also provide the name of an interface. This flag is necessary for the example application as each service runs in a different container and cannot reach the other services on the loopback address.
Note
You may encounter a permission denied error when creating the allocation directory. If so, run the nomad agent command without sudo
.
Leave Nomad running in this terminal session.
In a second terminal session, export the cluster address.
Verify connectivity
Verify connectivity to the cluster by checking the status of the nodes. The output you see may be different than the example output depending on where your cluster is running and how many nodes it has.
Browse the web UI
Navigate to the Nomad UI in your web browser by visiting http://localhost:4646/ui
(opens in new tab).
Visit the Servers page from the left navigation to see the server nodes in the cluster and the Clients page to see the client nodes. These pages will show only one node each if you are running a local development agent.
Visit the Topology page to see an overview of the clients, the resources available on each, and the total resources available to the cluster.
Next steps
In this tutorial you created a Nomad cluster. Continue on to the next tutorial by clicking on the Next button below and learn how to submit and run a job.