Allows scheduling of systemd units on a nomad cluster
$ sudo nomad agent -dev -plugin-dir "$PWD/plugins" # Load the systemd unit onto systemd $ cp webserver@.service /run/systemd/system $ systemctl daemon-reload $ nomad run example.hcl ==> Monitoring evaluation "2d88260e" Evaluation triggered by job "webserver" Allocation "156db366" created: node "e4557f90", group "webserver" Allocation "56342677" created: node "e4557f90", group "webserver" Allocation "83727afd" created: node "e4557f90", group "webserver" Allocation "9576f47e" created: node "e4557f90", group "webserver" Allocation "ec4c0d0d" created: node "e4557f90", group "webserver" Evaluation status changed: "pending" -> "complete" ==> Evaluation "2d88260e" finished with status "complete" $ [arian@t490s:~]$ systemd-cgls --unit system-webserver.slice Unit system-webserver.slice (/system.slice/system-webserver.slice): ├─firstname.lastname@example.org │ └─4259 /usr/bin/python -m http.server 27434 ├─email@example.com │ └─4260 /usr/bin/python -m http.server 28809 ├─firstname.lastname@example.org │ └─4261 /usr/bin/python -m http.server 23963 ├─email@example.com │ └─4258 /usr/bin/python -m http.server 21838 └─firstname.lastname@example.org └─4262 /usr/bin/python -m http.server 20124
Systemd should be configured to uphold resource limits that nomad allocates for
the job. If CPU limits are found, systemd should throttle the unit, and if
memory limits are reached, systemd should terminate the unit. Hence, this
plugin will implicitly enable
MemoryAccounting for the
units that it schedules. It will also implicitly set
LimitMemory fields appropriately. Overriding these values is not recommended
for now. The user may set other limits on their units though.
It is important that systemd never restarts units that are defined by the
plugin. Hence we will override each unit with a
RestartPolicy=never. If a
systemd unit crashes, it's up to nomad to decide whether it should be restarted
on the same machine or re-scheduled on another machine. If the user sets
RestartPolicy we will ignore it.
StateDirectory should be used with care because we do not migrate
state when a unit is scheduled on a new machine.
Nomad will mount
/secrets into the systemd unit.
Perhaps these in the future will be mounted under RuntimeDirectory=<unit_name>
but we haven't really decided yet.
When a unit isn't parameterized only one will exist per box. that's probably not what you want.
https://www.nomadproject.io/docs/job-specification/restart.html might conflict with the restart policy the unit itself has. Use either one, not both.
Logs are propagated to nomad, but not to journalctl