There's these instructions from redhat but they're cooking their own flyway.
Here's what I've done:
I have a dockerfile that looks like this:
FROM boxfuse/flyway ADD ./flyway /flyway #TODO: pass the username/password in from kubernetes CMD ["-X", "-url=jdbc:mysql://db-service", "-schemas=myapp", "-user=root", "-password=P@ssw0rd", "migrate"]
And I build it with:
docker build -t flyway-migrate:3 .
3 is the number that the flyway migration is up to.
I then have a kubernetes job to run this script:
apiVersion: batch/v1 kind: Job metadata: name: flyway-job spec: template: metadata: labels: app: java-app tier: flyway track: stable spec: containers: - name: flyway image: "flyway-migrate:3" imagePullPolicy: IfNotPresent restartPolicy: Never
This works fine, but there's a few questions I have.
- Whenever increment the flyway migration number, I have to rebuild the image, and then update the job, and delete the existing job and recreate it.
- Is there a way to rerun jobs?
- Is there a way to run the kubernetes job saying 'Use this image tag'.