
HashiCorp Nomad is a flexible scheduler and workload orchestrator that enables you to deploy and manage diverse workloads of docker containers, non-containerized applications, microservices, and batch jobs in a single, unified workflow. Nomad supports multiple plugins to synchronize with a system's hardware devices, such as GPUs, Field-Programmable Gate Arrays (FPGAs), and storage devices. In addition, Nomad supports cluster linking across regions to deploy jobs while automatically synchronizing policies and resource settings.
Follow this guide to deploy a HashiCorp Nomad cluster on Vultr using multiple instances. You will set up a Nomad cluster with three servers and two clients running Ubuntu 24.04 to run multiple jobs within the cluster.
Before you begin, you need to:
Nomad uses the client-server architecture in which servers manage the cluster while clients run applications. Servers and clients use a lightweight protocol for communication, enabling seamless scalability and large-scale orchestration tasks. Within a Nomad cluster:
Follow the steps below to deploy all Vultr Cloud Compute instances and install Nomad using Cloud-Init to create a new cluster.
Open the Vultr Console.
Select your desired instance type in the Choose Type section.
Choose the Vultr location to deploy your instance.
Select the instance specifications within the Plans section.
Click Configure Software to set up the instance information.
Select Ubuntu 24.04 X64 in the Operating System tab.
Click Limited User Login within the Additional Features section to enable a non-root sudo user.
Click Cloud-Init User-Data.
Add the following configuration to the User Data field. Replace the NOMAD_VERSION value with the latest version available on the Nomad releases page.
Review the instance summary and increase the Quantity value to 5.
Click Deploy to deploy the instances and install Nomad.
Attach all instances to the same VPC network as the Vultr Load Balancer.
Verify that the Vultr Load Balancer, Instances, and VPC network are deployed in the same Vultr location to ensure communication within the cluster.
Follow the steps to set up the required Nomad configurations on all instances including servers and clients.
Access each instance using SSH.
View the installed Nomad version.
Output:
Create a new Nomad configurations directory.
Create the Nomad data directory.
Enable the 755 permissions mode on the Nomad directories to allow global read privileges for all users.
Create a new Nomad systemd service file.
Add the following configurations to the nomad.service file.
Save and close the file.
The above configuration creates a new system service to run the Nomad agent binary using /etc/nomad.d as the configurations directory.
Reload systemd to apply the service configuration changes.
Enable the Nomad service to start at boot.
Start the Nomad service.
Follow the steps below to create the Nomad server configuration on all three servers within the Nomad cluster.
View the IP network information and note the instance's VPC network address.
Output:
enp8s0 is the VPC network interface with the private IP address 10.50.112.5 based on the above output.
Create a new nomad.hcl file in the /etc/nomad.d/ configurations directory.
Add the following configurations to the file. Replace the retry_join values with the actual network addresses for other servers in the Nomad cluster.
Save and close the file.
The above configuration enables the Nomad agent to listen for connection requests using all network addresses 0.0.0.0. The advertise section specifies the Vultr Load Balancer's public IP address to advertise Nomad cluster requests while the server_join section specifies the private addresses for each server within the Nomad cluster.
Restart the Nomad service to apply the configuration changes.
Allow all network connections on the VPC network interface through the default firewall. Replace enp8s0 with your actual VPC network interface name.
Reload UFW to apply the firewall configuration changes.
Perform the above steps on all servers within the Nomad cluster and switch the VPC network addresses within the Nomad configuration to match the neighboring server to ensure communication between the hosts.
Follow the steps below to create a new Nomad configuration on all clients within the cluster.
Create a new nomad.hcl configuration within the /etc/nomad.d/ directory.
Add the following configurations to the nomad.hcl file. Replace <PRIVATE_IP_SERVER_1>, <PRIVATE_IP_SERVER_2>, and <PRIVATE_IP_SERVER_3> with the VPC network addresses for the respective Nomad servers.
Save and close the file.
The above configuration enables the client configuration to join the Nomad cluster and send keep alive requests to all servers.
Restart the Nomad service to apply the configuration changes.
Allow all network connections from the VPC interface through the firewall.
Reload UFW to apply the firewall changes.
Perform the above steps on all Nomad clients to ensure network communication with servers in the cluster.
Follow the steps below to test the connectivity and verify the Nomad cluster status on all hosts.
Perform the following steps on each Nomad server.
Run the following command to view the Nomad servers information and status.
Monitor the Leader column and verify the main server in your output similar to the one below.
Test the connection to each Nomad server and the client's VPC address using the Ping utility.
Perform the following steps on each Nomad client.
Run the following command to view the Nomad clients information and status.
Output:
Test the connection to each Nomad server and client's VPC address and verify that it's successful.
Follow the steps below to connect your Vultr Load Balancer to all servers in the Nomad cluster.
Access your Vultr Load Balancer instance's management page.
Click Attach Instance and select all Nomad servers to link to the Load Balancer.
Navigate to the Configuration tab.
Click Forwarding Rules on the left navigation menu.
Create a new rule to forward traffic to the TCP port 4646 from the Load Balancer to port 4646 on all Nomad servers.
Update the Load Balancer's health checks configuration and set TCP as the protocol and 4646 as the port.
Follow the steps below to access the Nomad cluster interface and verify the status of all servers and clients.
Access your domain on port 4646 or the Vultr Load Balancer IP address in a web browser such as Chrome.
Click Servers on the left CLUSTER navigation menu to view the status of each Nomad server.
View the Status column and verify that each server is marked as Alive.
Verify the leader server within the Nomad cluster.
Click Clients and verify the status of all active clients, including the ID, name, state, and number of running tasks or allocations.
View the State column and verify that each client is Ready and able to run jobs.
Click Topology to view the cluster details and monitor metrics such as CPU, memory usage, and all active nodes.
Verify the available resources and node capacity to ensure that your cluster can efficiently handle workloads.
Use the topology view to identify cluster issues such as over-provisioned clients and resource shortages.
Follow the steps below to create a sample job deployment using any active Nomad server in the cluster.
Create a new hello.nomad file.
Add the following configurations to the file.
Save and close the file.
Run the job.
Output:
Check the status of the job.
Output:
Access the Nomad UI.
Navigate to Jobs and verify that the job is active.
Click the job to open its management page and monitor its runtime information.
Stop the job.
Output:
Follow the steps below to run simulations to test the cluster resilience.
Follow the steps below to identify the leader server and simulate a failure to verify that the cluster stays operational.
Run the following command on any Nomad server to identify the leader.
Output:
nomad-server-1.global is the leader server based on the above output.
Access the leader server and stop the Nomad service.
Check the Nomad server status using an active server and verify that a new cluster leader is elected.
Output:
Start the original leader server again.
Verify that the server rejoins as a follower.
Output:
Follow the steps below to simulate a failure of a client node and verify that the cluster stays operational.
Check the client node status on any Nomad server.
Output:
Stop the Nomad service on any client node.
View the Nomad client status again and verify that its status changes to down.
Output:
Restart the client node.
Verify that the client node status returns to ready.
Output:
You have deployed a Hashicorp Nomad cluster using Vultr Cloud Compute Instances and created a sample job deployment to test its functionality. You can deploy applications in the cluster and set up multiple clients depending on your project needs. Visit the Vultr CSI repository to enable the creation of Vultr Block Storage volumes in your Nomad cluster. For more information and scaling options, visit the Nomad documentation.
0 Comments
Be the first to comment and share your perspective with the community.