Working on a project which is a k8s service which is implemented using flask.
As part of the deployment, I'd like to run db migrations before the app starts execution.
I was wondering what is considered "best practice", and why.
Just mentioning here some of the ideas I had in mind:
if you had other approach/technique, be my guest :)
Thanks in advance!
The best practice would be to wrap all your app-related Kubernetes files in a helm chart, add the migration in a post-upgrade-hook which will ensure that is only run one time.
The problem with entrypoint.sh
is that if you have more than 1 pod in your deployment, the migration will be run more than once...
More info on helm chart hooks: