Everyone loves Kubernetes, right? Well, no not right, but it is one of the most popular container orchestrators out there.
However, it’s not the only orchestrator to manage containers.
One of the “up and coming” orchestrators that organizations are beginning to adopt is HashiCorp Nomad.
In this blog post, you’ll learn about what Nomad is, why it’s useful, and how to deploy it.
What’s Nomad?
First, what is Nomad? Is it any different than Kubernetes or Elastic Container Service (ECS) or Docker Swarm?
Technically, they’re all the same. At a high level, the job of an orchestrator is to schedule, scale and self-heal workloads. Those workloads are typically containers.
So yes and no - Nomad is different, but it’s the same.
Nomad actually gives you the ability to not only deploy, schedule, and scale containers, but virtualized applications as well. This is something that Kubernetes currently cannot do (unless you use kube-virt) out of the box, so it’s a great method if you have workloads outside of containers.
Nomad is an orchestrator that was created by HashiCorp. Although adoption hasn’t been ridiculously fast, there are definitely organizations that are now beginning to look at Nomad and adopt it.
Deploying Nomad
Now that you know what Nomad is (at a high level), let’s learn how to install it.
First, ensure that your Linux distro is up to date. For the purposes of this blog, Ubuntu will be used.
sudo apt update -y
Next, download the release repo.
curl -fsSL [https://apt.releases.hashicorp.com/gpg](https://apt.releases.hashicorp.com/gpg) | sudo apt-key add -
Add the HashiCorp repo to Aptitude.
sudo apt-add-repository "deb [arch=amd64] [https://apt.releases.hashicorp.com](https://apt.releases.hashicorp.com/) $(lsb_release -cs) main"
Update the repo and install Nomad.
sudo apt-get update && sudo apt-get install nomad
Next, download the Container Network Interface (CNI).
curl -L -o cni-plugins.tgz [https://github.com/containernetworking/plugins/releases/download/v1.0.1/cni-plugins-linux-amd64-v1.0.1.tgz](https://github.com/containernetworking/plugins/releases/download/v1.0.1/cni-plugins-linux-amd64-v1.0.1.tgz)
Create a new directory for the CNI.
sudo mkdir -p /opt/cni/bin
Extract the CNI binary and move it to the directory that you created previously.
sudo tar -C /opt/cni/bin -xzf cni-plugins.tgz
Start the agent. The command below runs Nomad in a dev environment and should be used for experimental use only.
sudo nomad agent -dev -bind 0.0.0.0 -log-level INFO
Open up a website over port 4646
on the IP address of the Linux server that you installed Nomad on.
You should now see Nomad running.
Deploying An App
Once the cluster is up, let’s deploy an application.
You have a few options to deploy apps (like apps that aren’t containerized), but to keep things simply, let’s use an Nginx docker image to deploy.
The code below indicates:
- Where you want the Job deployed.
- The port that the containerized app should be available on.
- The replica count.
- The container image.
job "httpnginx" {
datacenters = ["dc1"]
group "echo" {
network {
mode = "bridge"
port "http" {
static = 8080
to = 80
}
}
count = 2
task "server" {
driver = "docker"
config {
image = "nginx"
ports = ["http"]
}
}
}
}
You have two options to deploy the job.
First, you can use the UI and paste in the code above.
If you’d prefer to use the CLI, you can save the code above in an hcl
file and use the nomad run
command.
nomad run nginx.hcl
You’ll now see that the job is running successfully.
That's how you can get started in just a few minutes with Nomad! Thanks for reading.