Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nomad_job has missing namespace arguments #361

Open
rt232 opened this issue Jul 27, 2023 · 1 comment
Open

nomad_job has missing namespace arguments #361

rt232 opened this issue Jul 27, 2023 · 1 comment

Comments

@rt232
Copy link

rt232 commented Jul 27, 2023

In an enterprise deployment that multi-tenants, we need to deploy our jobs into separate environments, such as UAT01, SIT04, DEV02, etc. The same jobspec can be targeted to any of those environments. Environments are implemented as namespaces. Nomad namespace in which the job runs and because its the same job name, it has its own consul namespace in which it registers, so a 'customer' service is not uniquely named across the platform but is unique in its namespace context.

All is fine with the CLI, we specify -namespace and -consul-namespace and job deploys and runs as expected.

We've decided that we can manage what runs in the namespaces by using terraform to perform deployments and manage state. This is essential to the way we want to deal with runtimes and the aggregation of jobs into applications into fully functional environments.

The nomad_job resource is not on parity with the CLI options. First problem is there's no nomad namespace arg. So, this would force us to add a boiler plate 'namespace' variable to every job spec then blend it into the job variables we need to pass in with the HCL2 vars. Then there's the question of specifying the consul namespace too. and I've not mentioned Vault...

We want to move to using Nomad Pack for template rendering. From the nomad-pack CLI, its similarly possible to specify the vault, consul and nomad namespaces. With no terraform support for nomad-pack we could use the nomad-pack render capability and take the HCL to feed into the nomad_job jobspec BUT.... we're back to the issue of not supporting namespaces and so all the generic packs are likely not to work or need butchering to add boilerplate namespace rendering, etc

So, the request here is for CLI parity and nomad_job resource to support namespace - For full parity this would be arguments of consul, nomad and vault namespace

@rt232 rt232 changed the title nomad_job does missing namespace arguments nomad_job has missing namespace arguments Jul 27, 2023
@lgfa29
Copy link
Contributor

lgfa29 commented Jul 27, 2023

Hi @rt232 👋

Thanks for the suggestion. Unfortunately this is something we tried to implement in the past (#125) but learned that is not possible at this point because of #1, and the same apply to all other fields.

At the time we expected to have a fix for #1, but that turned out to not be feasible.

One alternative I thought of just now would be to have a separate block to override job values at submission, so it would be something like this:

resource "nomad_job" "my_job" {
  jobspec = "..."

  job_overrides {
    namespace        = "my-namespace"
    consul_namespace = "other-namespace"
    # ...
  }
}

Since they would be stored in a separate state path it would not clash with the computed attributes at the top-level. That block would be fairly limited in terms of which attributes would be supported, but that could be a good compromise for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants