How to update a job without creating new allocations

I’d like to update a Nomad job but keep the current allocations running. Here’s my use case.

My use case is I have a Redis job running that I’d like to update a config option while avoiding downtime. I can update the config option within the Redis CLI with CONFIG SET repl-diskless-sync yes so that’s fine. But if Redis needs to suddenly restart then it would no longer have this config option set so I need to also add this config option to redis.conf within the Redis container. So I’d like to update the job with this container but only for new allocations while keeping the existing allocations running. I hope that makes sense.

Is this achievable with Nomad or can anyone suggest an alternative strategy? Thanks

1 Like

Hi @axsuul,

Your description makes sense. There are probably a couple of ways to achieve this, depending on what your cluster topology looks like; the latter is the best option in my opinion.

Nomad Volume Mounts: you could store your config files on the client filesystem and then mount this inside the task using volume mounts. This does depend on the file being on all clients and being updated correctly, which depends on your cluster size and automation maturity.

Consul: you could store the Redis config within Consul KV which is then read by the Nomad job using the template block using the key template function. When you update the Consul KV entry, the Nomad template block will be notified of this, and update the rendered template with the new data. The template block params help control what action is taken when a template is modified.

Thanks,
jrasell and the Nomad team

@jrasell Thanks that helps a lot! The Consul KV option does sound preferable, sounds like I would probably use change_mode = "noop" then for the template.

Do you foresee Nomad ever supporting a use-case like mine natively however? I’d still prefer to keep the config in version control.

Hi @axsuul,

Yes! Here is the umbrella issue to a feature currently being worked on by the team: Secure Variables · Issue #12802 · hashicorp/nomad · GitHub

Thanks,
jrasell and the Nomad team

@jrasell Sorry! I mean, being able to update a job but not force it onto the current allocation yet (as mentioned in the first post).