Hi,
I am investigating a method of running database migrations (Ruby on Rails, Django, etc) in Helm in a Job with “helm.sh/hook”: pre-install,pre-upgrade . By all accounts, it should work fine. This seems like the best way to run database migrations via a helm deployment.
However, in a blog post someone mentioned that if the Job takes too long it might time out.
Would Helm’s global 5 minute timeout apply to pre-install jobs? That is, if a Job takes more than 5 minutes, for whatever reason, any reason, even if it’s constantly returning data to stdout/stderr, then Helm will consider that the Job has “timed out”? What are the criteria for a timeout to happen on a pre-install Job in Helm?
Thanks.
Hello @sdarwin did you find a solution, I been trying to run Django helm chart with pre-install,pre-upgrade jobs but keep getting error
I will appreciate if you or any member could share your solution
Hi Stephen,
You didn’t mention the errors you were getting. This thread was a general question about timeouts. Otherwise migrations were working. Here’s an example, it would have to be modified for your environment.
apiVersion: batch/v1
kind: Job
metadata:
name: database-migrations-job
labels:
env: {{ .Values.deploymentEnvironment }}
app: boost
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "-1"
spec:
ttlSecondsAfterFinished: 3600
backoffLimit: 4
template:
spec:
restartPolicy: OnFailure
volumes:
{{ toYaml .Values.Volumes | indent 6 }}
containers:
- name: database-migrations
image: {{ .Values.Image }}:{{ .Values.ImageTag }}
command: ["/bin/sh", "-c"]
args:
- "./manage.py migrate --noinput"
env:
{{ toYaml .Values.Env | indent 10 }}
volumeMounts:
{{ toYaml .Values.VolumeMounts | indent 10 }}