Support PostgreSQL DB migration and initialization for Auto DevOps
Problem to solve
Apps need to have databases configured before they work, and migrations run when they're updated. Auto DevOps doesn't currently support methods to initialize or migrate databases.
Further details
When apps are first deployed, they sometimes need a database to be initialized before they'll even start running.
When apps are updated and migrations are needed, they'll sometimes fail until the migrations are performed
Proposal
Option 1
Implement support for db initilization and migration for auto devops.
On initialize:
- Create post install hook
- initialize
- restart app
On migration:
- Create pre-upgrade hook
- run migration
Pseudocode:
-
if
$DB_INITIALIZE
- Create post-install hook:
- run
$DB_INITIALIZE
- restart app pods
- run
- Create post-install hook:
-
if
$DB_MIGRATE
- Create pre-upgrade hook:
- run
$DB_MIGRATE
- run
- Create pre-upgrade hook:
Option 2
Split up the helm chart into a db chart and an app chart. This allows for separate deployment of db with a post-install hook to initialize. Application can then be started after db in configured.
Option 3
User kubernetes custom controllers (operators) to do this outside of helm. There seem to be already some existing postgres operators that could be leveraged.
What does success look like, and how can we measure that?
(If no way to measure success, link to an issue that will implement a way to measure this)
Notes/Questions
-
How can we know how to run database commands for every language? Some buildpacks have this built in, but some don't (notably Ruby/Rails buildpack). Ideally we'd just rely on Herokuish to configure this for us, but it doesn't work. Even if we have good defaults, some teams may need to customize their database initialization and migration commands.
-
Keep env variables generic (ie
$initialize
,$pre_deploy
,$post_deploy
Links / references
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.