hashicorp / hashicorp/nomad

[Feedback] Nomad 0.11 lifecycle insufficient for 3 phase deploys

Open
#8,039 7 comments 5 reactions 0 assignees View on GitHub
theme/task lifecycle type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

Nomad 0.11 introduced `lifecycle` stanza which is a much needed resource. According to the [blogpost](https://www.hashicorp.com/blog/hashicorp-nomad-task-dependencies/) you are looking for feedback

One use case this doeesn't cover is when you have 3 steps

- postgres server
- seed database
- start web server

Here is an example job

https://gist.github.com/spuder/54f4b54a86d4690a76bfc4ed8eecc415

I've set the following

- postgres server
```
task "postgres" {
driver = "docker"
config {
image = "postgres:9.6-alpine"
}
lifecycle {
sidecar = true # <= calling this a sidecar doesn't really seem right. It does ensure it will keep running
hook = "prestart"
}
```
- seed database
```
task "seed_database" {
driver = "docker"
lifecycle {
sidecar = false # <= this allows the job to run then exit
hook = "prestart"
}
config {
image = "redash/redash:8.0.0.b32245"
command = "create_db"
}
...
```
- start web server

While this _mostly_ works, and the seed database job always runs before the web server, it doesn't guarantee that postgres will be up before the seed database job.

There needs to be a way to allow for 3 services to be chained together

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Nomad's lifecycle stanza and the linked example job, focusing on how the postgres, seed_database, and web server tasks are ordered. Done means a three-phase deployment can guarantee that postgres is ready before the seed job runs, and that the web server starts afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go, postgresql
Domain
devops, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.