Code Monkey home page Code Monkey logo

nomad-driver-systemd's Introduction

nomad-driver-systemd

Allows scheduling of systemd units on a nomad cluster

Example

$ sudo nomad agent -dev -plugin-dir "$PWD/plugins"
# Load the systemd unit onto systemd
$ cp [email protected] /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):
├─[email protected]
│ └─4259 /usr/bin/python -m http.server 27434
├─[email protected]
│ └─4260 /usr/bin/python -m http.server 28809
├─[email protected]
│ └─4261 /usr/bin/python -m http.server 23963
├─[email protected]
│ └─4258 /usr/bin/python -m http.server 21838
└─[email protected]
  └─4262 /usr/bin/python -m http.server 20124

Configuring systemd

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 CPUAcocunting and MemoryAccounting for the units that it schedules. It will also implicitly set LimitCPU and 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.

Features like StateDirectory should be used with care because we do not migrate state when a unit is scheduled on a new machine.

Nomad will mount /alloc, /local and /secrets into the systemd unit. Perhaps these in the future will be mounted under RuntimeDirectory=<unit_name> but we haven't really decided yet.

Upcoming features and TODOs

  • Allow scheduling (and downloading?) of portable services
  • Propagate nomad resource settings to systemd.resource-control options
  • Report resource utilization by querying the Cgroup tree

Caveats

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

nomad-driver-systemd's People

Contributors

arianvp avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.