Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
builtin/nomad-jobspec: better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Apr 8, 2021
1 parent 91b1ea1 commit 1faa45d
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion builtin/nomad/jobspec/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,35 @@ Deploy to a Nomad cluster from a pre-existing Nomad job specification file.
This plugin lets you use any pre-existing Nomad job specification file to
deploy to Nomad. This deployment is able to support all the features of Waypoint.
You may use Waypoint's [templating features](https://www.waypointproject.io/docs/waypoint-hcl/functions/template)
You may use Waypoint's [templating features](/docs/waypoint-hcl/functions/template)
to template the Nomad jobspec with information such as the artifact from
a previous build step, entrypoint environment variables, etc.
### Artifact Access
You may use Waypoint's [templating features](/docs/waypoint-hcl/functions/template)
to access information such as the artifact from the build or push stages.
An example below shows this by using ` + "`templatefile`" + ` mixed with
variables such as ` + "`artifact.image`" + ` to dynamically configure the
Docker image within the Nomad job specification.
### Entrypoint Functionality
Waypoint [entrypoint functionality](/docs/entrypoint#functionality) such
as logs, exec, app configuration, and more require two properties to be true:
1. The running image must already have the Waypoint entrypoint installed
and configured as the entrypoint. This should happen in the build stage.
2. Proper environment variables must be set so the entrypoint knows how
to communicate to the Waypoint server. **This step happens in this
deployment stage.**
**Step 2 does not happen automatically.** You must manually set the entrypoint
environment variables using the [templating feature](/docs/waypoint-hcl/functions/template).
One of the examples below shows the entrypoint environment variables being
injected.
`)

doc.Example(`
Expand All @@ -201,13 +227,35 @@ deploy {
`)

doc.Example(`
// The waypoint.hcl file
deploy {
use "nomad-jobspec" {
// Templated to perhaps bring in the artifact from a previous
// build/registry, entrypoint env vars, etc.
jobspec = templatefile("${path.app}/app.nomad.tpl")
}
}
// The app.nomad.tpl file
job "web" {
datacenters = ["dc1"]
group "app" {
task "app" {
driver = "docker"
config {
image = "${artifact.image}:${artifact.tag}"
}
env {
%{ for k,v in entrypoint.env ~}
${k} = "${v}"
%{ endfor ~}
}
}
}
}
`)

doc.SetField(
Expand Down

0 comments on commit 1faa45d

Please sign in to comment.