neomantra / nomad-skeleton-device-plugin

A template for writing a Nomad device plugin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nomad Skeleton Device Plugin

Skeleton project for Nomad device plugins.

This project is intended for bootstrapping development of a new device plugin.

Requirements

  • Nomad 0.9+
  • Go 1.19 or later (to build the plugin)

Building the Skeleton Plugin

Generate a new repository in your account from this template by clicking the Use this template button above.

Clone the repository somewhere in your computer. This project uses Go modules so you will need to set the environment variable GO111MODULE=on or work outside your GOPATH if it is set to auto or not declared.

$ git clone git@github.com:<ORG>/<REPO>git

Enter the plugin directory and update the paths in go.mod and main.go to match your repository path.

// go.mod

- module github.com/hashicorp/nomad-skeleton-device-plugin
+ module github.com/<ORG>/<REPO>
...
// main.go

package main

import (
    log "github.com/hashicorp/go-hclog"
    "github.com/hashicorp/nomad/plugins"

-   "github.com/hashicorp/nomad-skeleton-device-plugin/device"
+   "github.com/<REPO>/<ORG>/device"
)
...

Build the skeleton plugin.

$ make build

Running the Plugin in Development

You can test this plugin (and your own device plugins) in development using the plugin launcher. The makefile provides a target for this:

$ make eval

Deploying Device Plugins in Nomad

Copy the plugin binary to the plugins directory and configure the plugin in the client config. Then use the device stanza in the job file to schedule with device support. (Note, the skeleton plugin is not intended for use in Nomad.)

About

A template for writing a Nomad device plugin.

License:Mozilla Public License 2.0


Languages

Language:Go 96.5%Language:Makefile 3.5%