I have database migrations which I'd like to run before deploying a new version of my app into a Kubernetes cluster. I want these migrations to be run automatically as part of a Continuous Delivery pipeline. The migration will be encapsulated as a container image. What's the best mechanism to achieve this?

Requirements for a solution:

* be able to determine if a migration failed so that we don't subsequently try to deploy a new version of the app into the cluster.
* give up if a migration fails - don't keep retrying it.
* be able to access logs to diagnose failed migrations.

I had assumed that the Jobs functionality in Kubernetes would make this easy, but there appear to be a few challenges:

* Kubernetes will [repeatedly re-run containers whose processes terminate with a non-zero exit code](https://github.com/kubernetes/kubernetes/issues/20255), even if the Job has a `restartPolicy` of `never`.
* blocking while waiting on the result of a queued-up job seems to require hand-rolled scripts

Would using "bare pods" be a better approach? If so, how might that work?