0.0
No commit activity in last 3 years
No release in over 3 years
Provide Nomad stanzas definition and serializer.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 12.3
~> 3.8

Runtime

 Project Readme

nomad-stanza

Provide Nomad stanzas definition and serializer.

Gem Version

Installation

Add the following lines to Gemfile:

gem 'nomad-stanza'

And execute:

$ bundle install

Or just install directly by:

$ gem install nomad-stanza

Usage

See lib/nomad/stanza/definition.rb for all stanza definitions.

job = Nomad::Stanza::Job.new(
  id: 'fluentd-job',
  type: 'service',
  region: 'global',
  datacenters: %w(dc1 dc2),
  group: [{
    id: 'fluentd-group',
    count: 2,
    task: [{
      id: 'fluentd-task',
      driver: 'docker',
      config: {
        image: 'fluent/fluentd:v1.6',
      },
      resources: {
        cpu: 1000,
        memory: 1024,
        network: {
          mbits: 1,
          port_map: {
            forward: {
              static: 24224,
            }
          },
        },
      },
      service: [{
        name: '${TASK}',
        port: 'forward',
        check: [{
          type: 'tcp',
          interval: '10s',
          timeout: '2s',
        }]
      }],
    }],
  }],
)

puts Nomad::Stanza::Serializer.serialize(job)

will output:

job "fluentd-job" {
  type = "service"
  region = "global"
  datacenters = ["dc1", "dc2"]
  priority = 50
  group "fluentd-group" {
    count = 2
    task "fluentd-task" {
      kill_timeout = "5s"
      shutdown_delay = "0s"
      driver = "docker"
      config {
        image = "fluent/fluentd:v1.6"
      }
      resources {
        cpu = 1000
        memory = 1024
        network {
          mbits = 1
        }
      }
      service {
        name = "${TASK}"
        port = "forward"
        check {
          type = "tcp"
          interval = "10s"
          timeout = "2s"
        }
      }
    }
  }
}

Limitation

Currently task config only support docker.