How to configure Nomad to reference CNI plugins location?

I’m having some trouble getting Nomad to reference the CNI plugins from the Debian 12 packages. The Debian 12 packages drop the CNI plugins in /usr/lib/cni:

$ dpkg -L containernetworking-plugins | grep loopback
/usr/lib/cni/loopback

and so I have a plugin config directive in /etc/nomad.d/nomad.hcl:

plugin "cni" {
  directory = "/usr/lib/cni"
}

however after a restart I’m getting log messages like so:

... msg="failed to setup alloc: pre-run hook \"network\" failed: failed to configure networking for alloc: failed to configure network: plugin type=\"loopback\" failed (add): failed to find plugin \"loopback\" in path [/opt/cni/bin]" failed=true

which seems to suggest that Nomad is still looking for CNI in /opt/cni/bin.

fwiw, I was able to get this working via:

mkdir -p /opt/cni && \
  cd /opt/cni && \
  ln -s /usr/lib/cni bin

but that’s sort of a cheap hack.

Hi @niftyjennins,

You can use the client.cni_path configuration parameter to specify where the CNI plugins can be found along with the client.cni_config_dir to specify the path to any CNI configuration files.

Your configuration could therefore look like:

client {
  cni_path = "/usr/lib/cni/"
}

Thanks,
jrasell and the Nomad team

1 Like

Thanks. FWIW, here is the working config for Debian 12 with the containernetworking-plugins package installed:

client {
  cni_path = "/usr/lib/cni"
  cni_config_dir = "/etc/nomad.d/cni_config"
}
1 Like