Write README

This commit is contained in:
Alex 2022-11-29 13:19:08 +01:00
parent 2a8db433c2
commit 0b203bf9f1
Signed by: lx
GPG key ID: 0E496D15096376BE

View file

@ -1,14 +1,9 @@
Nomad Skeleton Driver Plugin Nomad Nix Driver Plugin
========== ==========
Skeleton project for A Nomad driver to run Nix jobs.
[Nomad task driver plugins](https://www.nomadproject.io/docs/drivers/index.html). Uses the same isolation mechanism as the `exec` driver.
Partially based on [`nomad-driver-nix`](https://github.com/input-output-hk/nomad-driver-nix)
This project is intended for bootstrapping development of a new task driver
plugin.
- Website: [https://www.nomadproject.io](https://www.nomadproject.io)
- Mailing list: [Google Groups](http://groups.google.com/group/nomad-tool)
Requirements Requirements
------------------- -------------------
@ -16,69 +11,22 @@ Requirements
- [Go](https://golang.org/doc/install) v1.18 or later (to compile the plugin) - [Go](https://golang.org/doc/install) v1.18 or later (to compile the plugin)
- [Nomad](https://www.nomadproject.io/downloads.html) v0.9+ (to run the plugin) - [Nomad](https://www.nomadproject.io/downloads.html) v0.9+ (to run the plugin)
Building the Skeleton Plugin Building and using the Nix driver plugin
------------------- -------------------
[Generate](https://github.com/hashicorp/nomad-skeleton-driver-plugin/generate) To build the plugin and run a dev agent:
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](https://blog.golang.org/using-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.
```sh
$ 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.
```diff
// go.mod
- module github.com/hashicorp/nomad-skeleton-driver-plugin
+ module github.com/<ORG>/<REPO>
...
```
```diff
// 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.
```sh
$ 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:
```sh ```sh
$ make build $ make build
$ nomad agent -dev -config=./example/agent.hcl -plugin-dir=$(pwd) $ nomad agent -dev -config=./example/agent.hcl -plugin-dir=$(pwd)
# in another shell # in another shell
$ nomad run ./example/example.nomad $ nomad run ./example/example-batch.hcl
$ nomad run ./example/example-service.hcl
$ nomad logs <ALLOCATION ID> $ nomad logs <ALLOCATION ID>
``` ```
Code Organization Writing Nix job specifications
------------------- -------------------
Follow the comments marked with a `TODO` tag to implement your driver's logic.
For more information check the See documentation comments in example HCL files.
[Nomad documentation on plugins](https://www.nomadproject.io/docs/internals/plugins/index.html).