Search code examples
nomad

Nomad host_volume not mounted


I'm trying to mount /var/log directory so that my tasks can access the files in this directory. How can I update my config for this directory to be mounted?

  • nomad running in dev mode (single cluster)
  • I am aware of this ticket, not too sure what's the status of it. But I have restarted nomad server + client by sending SIGHUP, SIGKILL, SIGQUIT with htop, also tried ctrl+c + start, also tried systemctl restart/start/stop.
  • running on ubuntu 23.08
  • nomad v1.7.2

/etc/nomad.d/nomad.hcl

server {
  # license_path is required for Nomad Enterprise as of Nomad v1.1.1+
  #license_path = "/etc/nomad.d/license.hclic"
  enabled          = true
  bootstrap_expect = 1
}

client {
  enabled = true
  servers = ["127.0.0.1"]

  host_volume "dir-var-log" {
    path = "/var/log"
    read_only = true
  }
}

Output of nomad node status -short -self:

root@observability-test:~# nomad node status -short -self
ID              = b037c0e7-b2f0-3248-c98d-d6b557c5e758
Name            = observability-test
Node Pool       = default
Class           = <none>
DC              = dc1
Drain           = false
Eligibility     = eligible
Status          = ready
CSI Controllers = <none>
CSI Drivers     = <none>
Host Volumes    = <none> #<--- not picking up
Host Networks   = <none>
CSI Volumes     = <none>
Drivers         = exec,raw_exec

Don't think this is relevant, but here's relevant snippet of job spec:

job "my-job" {
  type = "system"

  group "my-group" {
    count = 1
    
    volume "dir-var-log"{
      type = "host"
      read_only = true
      source = "dir-var-log" # This is from client configuration file


    task "my-task" {
      driver = "exec"
      
      volume_mount {
        volume = "dir-var-log"
        destination = "/var/log"
        read_only = true
      }

...


Solution

  • nomad agent doesn't read from /etc/nomad.d by default. You have to pass nomad agent -dev -config /etc/nomad.d explicitly.