Steps to Install & Configure HashiCorp Nomad on Ubuntu

Nomad is a free & open source HashiCorp tool.It is a simple and flexible workload orchestrator which is used for deploy and manage containers and non-containerized applications across on-prem and clouds at scale.

There are some steps to Setup HashiCorp Nomad on Ubuntu:

Step 1: Update the System.

apt update

Step 2:Install HashiCorp Nomad on system.

  • Add the HashiCorp GPG key.

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

  • Add the official HashiCorp Linux repository.

apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

  • Here is the command output.

  • Update the packages.

apt update

  • Install nomad.

apt-get install nomad

  • Here is the command output.

  • To list the available options in nomad.

nomad

  • Here is the command output.

Step 3: Open the following port numbers in UFW firewall.

ufw allow 4646:4648/tcp
ufw allow 4648/udp

  • Here is the command output.

  • Enable the UFW.

ufw enable

  • Type y.
  • Reload the ufw.

ufw reload

  • Here is the command output.

Step 4: Install the Nomad Agent & Run the command in backend using & option.

nomad agent -dev -bind 0.0.0.0 -log-level INFO &

  • Here is the command output.

  • To Check the running command in backend,run jobs command.

jobs

  • To view the registered nodes of the Nomad cluster.

nomad node status

  • Here is the command output.

  • To view the running members of server.

nomad server members

  • To view the running members of server in details.

nomad server members -detailed

  • Here is the command output.

Step 5: Create a Job.

  • Create a directory & navigate into it.

mkdir nomad
cd nomad

  • To generates a skeleton job file.

nomad job init

  • T0 list the skeleton job file,run ll command.

ll

  • Here is the command output.

  • Open the job file.

vim example.nomad

  • In the file,the following lines are available:

job "example" {
...
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
port_map {
db = 6379
}
}
}
...
}

  • Run the skeleton job file.

nomad job run example.nomad

  • We get the following Error message because Docker is not installed or the Docker daemon is not loaded:

  • So,Install docker on System.

apt install docker.io

  • Run again skeleton job file.

nomad job run example.nomad

  • Here is the command output.

  • Check the status of job.

nomad status example

  • Here is the command output.

  • Check the status of allocations.

nomad alloc status Allocations-id
nomad alloc status 585c6f1f

  • Here is the command output.

  • Check the logs of a task.

nomad alloc logs Allocations-id redis
nomad alloc logs 585c6f1f redis

  • Here is the command output.

  • After any modification in the skeleton job file,run

nomad job plan example.nomad

  • Here is the command output.

  • Stop the job.

nomad job stop example

  • Here is the command output.

  • Check status of job.

nomad job status example

  • Here is the command output.

Leave a Reply

Your email address will not be published.