Skip to content

Instantly share code, notes, and snippets.

@moosh3
Created March 13, 2020 22:45
Show Gist options
  • Save moosh3/2df94138fdfef3945c0debfa992ed9f5 to your computer and use it in GitHub Desktop.
Save moosh3/2df94138fdfef3945c0debfa992ed9f5 to your computer and use it in GitHub Desktop.
apiVersion: batch/v1
kind: Job
metadata:
name: db-migrator
annotations:
"helm.sh/hook": post-install,pre-upgrade
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: Never
initContainers:
- name: check-db-ready
image: {{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
imagePullPolicy: {{ .Values.pullPolicy }}
env:
- name: PGHOST
value: {{ .Values.db.host }}
- name: PGPORT
value: "{{ .Values.db.port }}"
command: ['sh', '-c', 'until pg_isready; do echo waiting for database; sleep 2; done;']
containers:
- name: db-migrator
image: {{ .Values.dbMigrator.job.image.repository }}:{{ .Values.imageTag }}
imagePullPolicy: {{ .Values.pullPolicy }}
env:
- name: TERN_CONF
value: /home/db-migrator/.cfg/tern.conf
volumeMounts:
- name: db-migrator-config
mountPath: "/home/db-migrator/.cfg"
readOnly: true
command: ["./migrate.sh"]
volumes:
- name: db-migrator-config
secret:
secretName: db-migrator-config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment