hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.95k stars 1.96k forks source link

[feature request] be able override resources in parameterized job #8259

Open shantanugadgil opened 4 years ago

shantanugadgil commented 4 years ago

Nomad version

Nomad v0.11.3 (8918fc804a0c6758b6e3e9960e4eb2e605e38552)

Operating system and Environment details

CentOS 7/8, Ubuntu 18.04

Issue

I want to be able to register a parameterized job and then, be able to have different resource constraints for each dispatch of the job instance.

Also, if I were to move the meta from required to optional, how would I be able to specify a default value for the optional parameter?

Reproduction steps

Job file (if appropriate)

File: param1.nomad

job "param1" {
  type = "batch"

  parameterized {
    payload       = "forbidden"
    meta_required = ["CPU_VALUE"]
  }

  group "mygroup" {
    task "mytask" {
      driver = "raw_exec"

      config {
        command = "/bin/sleep"
        args    = ["300"]
      }

      resources {
        cpu    = "${NOMAD_META_CPU_VALUE}"  # this does not work (of course), but that's what I want to achieve
        memory = 256

        network {
          mbits = 100
        }
      }
    }
  }
}

Use Case

The parameterized job is used to build different software components, some require more CPU/MEMORY than others while building, hence reserving the same cpu/memory for each dispatch is "sub-optimal". n/a

tgross commented 4 years ago

I'm going to mark this with hcl because it's the sort of thing we might be able to improve upon when we embark on our HCL2 migration.

shantanugadgil commented 4 years ago

"embark" makes it sound quite far away! 😀

for now, I see just doing a full render (using levant/or equivalent) which will set job and task specific values all over.

just updating, in case anyone else reaches here while searching

tgross commented 2 years ago

https://github.com/hashicorp/nomad/issues/12228 was a duplicate of this and I've closed that. But that also made me realize I should have removed the hcl label from this one, as it really doesn't help for this use case because HCL2 parsing is done in the CLI and not in the server.

RCM7 commented 1 year ago

☝️ +1 this would come really handy

shemi-plgs commented 1 year ago

+1 this would really help me too