Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stephenhillier/5767ede486bad1fad63a991ac8951c3b to your computer and use it in GitHub Desktop.
Save stephenhillier/5767ede486bad1fad63a991ac8951c3b to your computer and use it in GitHub Desktop.
apiVersion: batch/v1
kind: Job
metadata:
name: myapp-db-migrate
namespace: myapp
spec:
backoffLimit: 5
activeDeadlineSeconds: 900
template:
spec:
shareProcessNamespace: true
restartPolicy: Never
containers:
- name: dbmate
image: stephenhillier/myapp-api:IMAGE_VERSION
imagePullPolicy: Always
command: ["/bin/sh", "-c"]
args: ["sleep 3; /app/dbmate -e DB_CONN -d /app/db/migrations migrate; exit_code=$?; pkill -INT /usr/local/bin/pilot-agent; exit $exit_code"]
env:
- name: DBHOST
valueFrom:
configMapKeyRef:
name: myapp-db
key: host
- name: DBPORT
valueFrom:
configMapKeyRef:
name: myapp-db
key: port
- name: DBPASS
valueFrom:
secretKeyRef:
name: db-credentials
key: password
- name: DBUSER
valueFrom:
secretKeyRef:
name: db-credentials
key: username
- name: DB_CONN
value: postgres://$(DBUSER):$(DBPASS)@$(DBHOST):$(DBPORT)/geo?sslmode=require
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment