I'm pushing my Phoenix app to a Kubernetes cluster for review. I use GitLab to create a service for the web server and another service for a temporary postgres pod.
What I would like to do is automate mix ecto.create
and mix ecto.migrate
. However, there is a timing issue - there's a short period of time when the postgres server is not ready yet.
I could poll the postgres service in my deployment script before creating the web application service. But is this the most practical method?
Kubernetes has something called init containers which may help you.
From the documentation, here is an example of an app container which waits for a dB container.