state-hub/deploy/railiance/apps/charts/state-hub/templates/migrate-job.yaml
tegwick 0b44cf12f5
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 45s
feat: complete cluster self-sufficiency hardening
Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a06d83-1cbc-71f2-b0dc-e0f48cedae43
2026-09-04 22:23:42 +02:00

51 lines
2 KiB
YAML

{{- if .Values.migrations.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "statehub.fullname" . }}-migrate
labels: {{- include "statehub.labels" . | nindent 4 }}
annotations:
# Run before the API starts serving, and before an upgrade swaps the image.
# A deployment that can serve against a schema it was not built for is the
# same class of defect as a projection that cannot name its source commit
# (STATE-WP-0083-T07).
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "-5"
# Keep a failed job for inspection; a silent migration failure is how the
# schema drifted two revisions behind the code in the first place.
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
backoffLimit: {{ .Values.migrations.backoffLimit }}
template:
metadata:
labels: {{- include "statehub.labels" . | nindent 8 }}
spec:
restartPolicy: Never
securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets: {{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: runtime-tmp
emptyDir: {}
containers:
- name: migrate
image: {{ include "statehub.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext: {{- toYaml .Values.securityContext | nindent 12 }}
command: ["/app/.venv/bin/python", "-m", "alembic", "upgrade", "head"]
volumeMounts:
- name: runtime-tmp
mountPath: /tmp
env:
- name: HOME
value: /tmp
envFrom:
{{- if .Values.config.enabled }}
- configMapRef:
name: {{ .Values.config.name | quote }}
{{- end }}
- secretRef:
name: {{ .Values.secret.name | quote }}
resources: {{- toYaml .Values.migrations.resources | nindent 12 }}
{{- end }}