How to define levels of start order and delay for LXC

jsabater

Member
Oct 25, 2021
115
11
23
48
Palma, Mallorca, Spain
Hey there!

I have a 5-node cluster with a lot of LXC which basically fall into these categories:
  1. Common services (e.g., internal DNS)
  2. Database servers (e.g. PostgreSQL)
  3. Application servers (e.g. Python applications running with Gunicorn)
  4. Web servers (e.g. NGINX as reverse proxy for the application servers).
  5. Other (e.g. monitoring, analytics).
I would like to use the start/shutdown order and startup delay options to make them start in the order mentioned above (I don't care about the "internal" order of each category) and, maybe, allow a few seconds between one level and the next (although this is a secondary objective).

Please let me know if this approach would be correct:
  1. Take all LXC in the level 1 and set start/shutdown order to 10. Level 2 would be 20, and up to level 5 with 50.
  2. All existing containers would have to be updated with a value, otherwise the default order (empty at the moment) would ruin the whole thing.
  3. Go to the LXC with the highest id of a given level and set the startup delay to 10 seconds (this is not really a handy solutions as they come and go, but I see no other option).
Would this be the right approach? Any better solution?

Thanks in advance.