Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nomad configuration for single node to act as production server and client

Tags:

nomad

How can I setup Nomad to act the same as it's development mode, but instead to run this as a production setup so it persists data? So that is nomad agent -dev.

Do I run the client / server processes repeatedly? Or can I configure it to run both?

So essentially a one node nomad cluster

like image 836
Chris Stryczynski Avatar asked Sep 16 '25 15:09

Chris Stryczynski


1 Answers

Since the other answer is valid in its criticism but didn't bother answering the question, here is what you can do for linux:

This assumes you have nomad installed at /usr/local/bin/nomad

Nomad config

Create the following config.hcl inside /etc/nomad.d. Make sure to replace the value of name from example config.

client {
  enabled = true
}
server {
  enabled = true
  bootstrap_expect = 1
}
datacenter = "dc1"
data_dir = "/opt/nomad"
name =  "YOUR_NOMAD_NAME_HERE"

The data will be persisted in data_dir (/opt/nomad in this example config)

Linux service

Then create a service nomad.service inside /etc/systemd/system/:

[Unit]
Description=Nomad
Documentation=https://nomadproject.io/docs/
Wants=network-online.target
After=network-online.target

[Service]
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/nomad agent -config /etc/nomad.d
KillMode=process
KillSignal=SIGINT
LimitNOFILE=infinity
LimitNPROC=infinity
Restart=on-failure
RestartSec=2
StartLimitBurst=3
TasksMax=infinity

[Install]
WantedBy=multi-user.target

And finally start it with systemctl enable nomad && systemctl start nomad

like image 124
ninjaintrouble Avatar answered Sep 19 '25 08:09

ninjaintrouble