A driver to run Nix jobs on Nomad
Find a file
2022-11-29 13:01:46 +01:00
example Works better and better, write some examples 2022-11-29 13:01:46 +01:00
executor Ability to run Nix jobs 2022-11-29 11:41:40 +01:00
nix2 Works better and better, write some examples 2022-11-29 13:01:46 +01:00
.gitignore Rename driver to nix2 2022-11-29 09:46:43 +01:00
GNUmakefile Rename driver to nix2 2022-11-29 09:46:43 +01:00
go.mod First build as external plugin 2022-11-28 12:37:50 +01:00
go.sum First build as external plugin 2022-11-28 12:37:50 +01:00
LICENSE Initial commit 2022-11-28 11:33:28 +01:00
main.go Rename driver to nix2 2022-11-29 09:46:43 +01:00
README.md Initial commit 2022-11-28 11:33:28 +01:00

Nomad Skeleton Driver Plugin

Skeleton project for Nomad task driver plugins.

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

Requirements

  • Go v1.18 or later (to compile the plugin)
  • Nomad v0.9+ (to run 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-driver-plugin
+ module github.com/<ORG>/<REPO>
...
// main.go

package main

import (
    log "github.com/hashicorp/go-hclog"
-   "github.com/hashicorp/nomad-skeleton-driver-plugin/hello"
+.  "github.com/<REPO>/<ORG>/hello"
...

Build the skeleton plugin.

$ make build

Deploying Driver Plugins in Nomad

The initial version of the skeleton is a simple task that outputs a greeting. You can try it out by starting a Nomad agent and running the job provided in the example folder:

$ make build
$ nomad agent -dev -config=./example/agent.hcl -plugin-dir=$(pwd)

# in another shell
$ nomad run ./example/example.nomad
$ nomad logs <ALLOCATION ID>

Code Organization

Follow the comments marked with a TODO tag to implement your driver's logic. For more information check the Nomad documentation on plugins.