Open thomaslepoix opened 1 year ago
Beside the user interface part, there is a serious problem on the current nomad-pack
impl: if a job is removed from a pack, nomad-pack run xxx
will not remove it from the deployment. (I've created a separate issue: https://github.com/hashicorp/nomad-pack/issues/503)
But you don't need nomad-pack
! It is possible to implement most nomad-pack features in Terraform's Nomad provider:
--preserve-counts
DOES NOT WORK, pending upstream changes
Here's some demo that you can try out.
Terraform:
resource "nomad_job" "xxx" {
jobspec = templatefile("${path.module}/job.nomad.hcl.tftpl", {
"key" = "value",
})
hcl2 {}
purge_on_destroy = true
}
Template:
job "name-${key}" {
// ...
}
(Escape all $
in the job template as $$
)
Just inject the relevant meta values by hand.
job "hello_world" {
type = "service"
namespace = "default"
meta = {
"pack.deployment_name" = "hello_world"
"pack.job" = "hello_world"
"pack.name" = "hello_world"
"pack.path" = "/nonexistent"
"pack.registry" = "<<local folder>>"
"pack.version" = "<<none>>"
}
group "hello" {
task "hello" {
driver = "docker"
config {
image = "k8s.gcr.io/pause:3.2"
}
resources {
cpu = 100
memory = 100
memory_max = 250
}
}
}
}
Use either Terraform modules in a git repository, or Terragrunt. It works like a charm.
Hello, I am really interested in using a registry of nomad jobs, but I am not interested in deploying jobs through imperative commands such as
nomad-pack run <pack>
. I'd rather not deviate from my current flow where all my jobs are described in files, deployed thanks to Terraform -> everything as code.Is there any plan to make nomad-pack available from either one of the following way?
By the way, I would be glad to use the nomad-pack CLI for various other tasks such as consulting registry list, generating pack from template, and so on.