Hashicorp Nomad Cluster Lab on Centos & RockyLinux

Introduction

We have been looking for alternative ways to utilize server resources for quite some time now straight forward approach for setup. It might not be production-ready, pretty sure it is worthwhile setting up for development. An orchestrator that makes our life easier. It is an automation management tool. Its provision, deploy, trigger, monitor, measure, track, and ensure the robot’s security in the organization.

So Kubernetes made for containers by Google.It intends to provide all the features for Linux container applications, including cluster management, scheduling, service discovery, monitoring, secrets management, and more.Hashicorp nomad only focuses on cluster management and scheduling and is designed with Unix philosophy having a small scope.Console composing tools for service discovery service mesh & Vault remote management.

Additionally, Kubernetes is a collection of a lot of interoperating services with full functionality.Storage and coordination provided by etcd at the core.

Besides, The state is API controllers consumed by other services that offer high-level APIs features like scheduler.Kubernetes supports high availability for configuration of operation complex to setup.

Also Nomad is much simpler.A single binary for clients and servers requires no external services for coordination or storage.Combines a lightweight manager and with a sophisticated scheduler. distributed, highly available, and operationally simple.

In addition to it is available as a pre-compiled binary for almost all operating systems.For macOS, you can get it from Homebrew for free and open source.For windows, install the from the chocolatey open-source package manager.With Linux, use yum, dnf, or apt to install the package.

Hashicorp nomand Installation in your system using dnf

So Hashicorp maintains and signs packages for on their repository.

So Create this file on /etc/yum.repos.d/hashicorp.repo with the content below.Would you please do this to all master and slave nodes?

Nomad – Documentation link

# vi /etc/yum.repos.d/hashicorp.repo
[hashicorp]
name=Hashicorp Stable - $basearch
baseurl=https://rpm.releases.hashicorp.com/RHEL/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://rpm.releases.hashicorp.com/gpg

[hashicorp-test]
name=Hashicorp Test - $basearch
baseurl=https://rpm.releases.hashicorp.com/RHEL/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://rpm.releases.hashicorp.com/gpg

Hashicorp nomad installation using yum

# dnf -y install nomad 
Last metadata expiration check: 0:11:47 ago on Sat 10 Jul 2021 07:10:43 AM UTC.
Dependencies resolved.
================================================================================================================ Package
          Architecture             Version                     Repository                   Size
================================================================================================================Installing:
 nomad                   x86_64                   1.1.2-1                     hashicorp                    26 M
 consul                       x86_64                       1.10.0-1                       hashicorp                        29 M

Transaction Summary
================================================================================================================Install  1 Pack
age

Total download size: 26 M
Installed size: 82 M
Downloading Packages:
nomad-1.1.2-1.x86_64.rpm                                                                       1.6 MB/s |  26 MB 
    00:15

-------------------------------------------------------------------------------------------------------------------------------
Total                                                                                          1.6 MB/s |  55 MB     00:15
warning: /var/cache/dnf/hashicorp-164999f2fbadbd87/packages/nomad-1.1.2-1.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a3
219f7b: NOKEY
Hashicorp Stable - x86_64                                                                      666  B/s | 3.1 kB     00:04
Importing GPG key 0xA3219F7B:
 Userid     : "HashiCorp Security (HashiCorp Package Signing) <security+packaging@hashicorp.com>"
 Fingerprint: E8A0 32E0 94D8 EB4E A189 D270 DA41 8C88 A321 9F7B
 From       : https://rpm.releases.hashicorp.com/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                       1/2
  Running scriptlet: nomad-1.1.2-1.x86_64                                                                                  2/2
Running scriptlet: consul-1.10.0-1.x86_64                                                                                  1/2
  Installing       : nomad-1.1.2-1.x86_64                                                                                  2/2
Installing       : consul-1.10.0-1.x86_64                                                                                  1/2
  Running scriptlet: nomad-1.1.2-1.x86_64                                                                                  2/2
  Verifying        : nomad-1.1.2-1.x86_64                                                                                1/2
Verifying        : consul-1.10.0-1.x86_64                                                                                2/2

Installed:
  nomad-1.1.2-1.x86_64    consul.x86_64

Complete!
[root@master8 ~]#

Hashicorp nomad verify the installation

# nomad
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
    deployment          Interact with deployments
    eval                Interact with evaluations
    exec                Execute commands in task
    license             Interact with Nomad Enterprise License
    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
    system              Interact with the system API
    ui                  Open the Nomad Web UI
    version             Prints the Nomad version
    volume              Interact with volumes
[root@master8 ~]#

Install the agent to all clients as well

So Now Configure the server Leader for the cluster

[root@master ~]# cat /etc/nomad.d/nomad.hcl
# Full configuration options can be found at https://www.nomadproject.io/docs/configuration

data_dir = "/opt/nomad/data"
datacenter = "antipolo"

server {
  enabled = true
  bootstrap_expect = 1
}

[root@master ~]#

Configure the client nodes

[root@worker1 ~]# cat /etc/nomad.d/nomad.hcl
# Full configuration options can be found at https://www.nomadproject.io/docs/configuration

data_dir = "/opt/nomad/data"
datacenter = "antipolo"

client {
  enabled = true
  servers = ["192.168.56.101"]
}

[root@worker1 ~]#

[root@worker2 ~]# cat /etc/nomad.d/nomad.hcl
# Full configuration options can be found at https://www.nomadproject.io/docs/configuration

data_dir = "/opt/nomad/data"
datacenter = "antipolo"

client {
  enabled = true
  servers = ["192.168.56.101"]
}

[root@worker2 ~]#

Now check the Leader if elected

[root@master ~]# nomad server members
Name                       Address         Port  Status  Leader  Protocol  Build  Datacenter  Region
master.example.com.global  192.168.56.101  4648  alive   true    2         1.1.2  antipolo    global

Check the client nodes status

[root@worker1 ~]# nomad node status
ID        DC        Name                 Class   Drain  Eligibility  Status
522508a4  antipolo  worker2.example.com  <none>  false  eligible     ready
7a357baa  antipolo  worker1.example.com  <none>  false  eligible     ready

Conclusion

This tutorial is to compare the capabilities and alternative solutions. We may want to remain to what you are using.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x