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

[Feedback] Nomad 0.11 lifecycle insufficient for 3 phase deploys #8039

Open
spuder opened this issue May 21, 2020 · 7 comments
Open

[Feedback] Nomad 0.11 lifecycle insufficient for 3 phase deploys #8039

spuder opened this issue May 21, 2020 · 7 comments

Comments

@spuder
Copy link
Contributor

spuder commented May 21, 2020

Nomad 0.11 introduced lifecycle stanza which is a much needed resource. According to the blogpost 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

@DhashS
Copy link

DhashS commented May 24, 2020

There’s a good amount of discussion here #419 - but the short of it is that nomad does not currently support this. We ended up using terraform to implement this

@tgross tgross added theme/dependencies Pull requests that update a dependency file type/enhancement labels May 26, 2020
@yishan-lin
Copy link
Contributor

We are planning on adding a PostStop hook to the Nomad 0.12 series. Would this be helpful?

@Legogris
Copy link

As a separate one, multiple prestarts which need to be run sequentially/in a particular order.

I can see two alternatives:

  1. A sequence/order/suitable name - like init.d runlevels
  2. depends_on a la systemd services

@DhashS
Copy link

DhashS commented Jun 18, 2020

@yishan-lin adding more hooks just solves it for an N stage deploy, where N is the amount of hooks you have. One can imagine that a 5-phase deploy where only the last phase is the main container needing a postprepreprestart hook or something heinous like that.

Docker-compose does this with the depends_on clause

@yishan-lin
Copy link
Contributor

Heard loud and clear. We’ll be introducing PostStop and PostStart hooks into the 0.12 series but know that doesn’t address the underlying limitations of such a design.

We’ll look to our airflow integration targeted in the fall to provide this functionality in a comprehensive manner to Nomad.

@tino
Copy link

tino commented Oct 8, 2020

I see that lifecycle works on task level. I would like it to work on a group level. Why?

Right now we run some auxiliary apps that need a redis database. Preferably I would put redis in a different group, so it can be spawned on a different node if necessary. Also I might need a higher count of workers than redis dbs. However now that means I have to put redis either in the same group so I can refer to its address with S{NOMAD_ADDR_redis_redis}, or put it in a separate nomad file and launch it first.

If I'm able to say: this group should be up before the other group, then we can register the redis task in consul, and use the service consul-template tag in the worker's env template to pass it the address.

@tgross tgross added theme/task lifecycle and removed theme/dependencies Pull requests that update a dependency file labels Mar 4, 2021
@Aposhian
Copy link

Aposhian commented Jan 8, 2022

Also currently blocked by this. I'm concerned that it seems the plan to support this simple use-case is to outsource to Apache Airflow. I have no interest in Airflow: I just need to specify a basic dependency chain, which is already possible in docker-compose or systemd.

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

7 participants