Files
cloud-host/backend/helm/cloudhost-platform/templates/migrations-job.yaml
T
keyhan bf9e827f85 Add cloudhost-platform Helm chart and registry ingress manifests.
Deploy backend, frontend, PostgreSQL, and Redis on Kubernetes with optional Ingress/TLS, SQL migration hooks, and public registry exposure at repo.3fase.ir.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-24 19:01:05 +03:30

63 lines
2.0 KiB
YAML

{{- if and .Values.migrations.enabled .Values.postgres.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "cloudhost-platform.fullname" . }}-migrations
namespace: {{ include "cloudhost-platform.namespace" . }}
labels:
{{- include "cloudhost-platform.labels" . | nindent 4 }}
annotations:
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-weight: "5"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
spec:
backoffLimit: 3
template:
spec:
restartPolicy: OnFailure
initContainers:
- name: wait-postgres
image: {{ .Values.images.busybox | quote }}
command:
- sh
- -c
- |
until nc -z {{ include "cloudhost-platform.postgres.fullname" . }} 5432; do
sleep 2
done
containers:
- name: migrate
image: {{ .Values.migrations.image | quote }}
env:
- name: PGHOST
value: {{ include "cloudhost-platform.postgres.fullname" . }}
- name: PGPORT
value: "5432"
- name: PGDATABASE
value: {{ .Values.postgres.database | quote }}
- name: PGUSER
value: {{ .Values.postgres.username | quote }}
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "cloudhost-platform.secretName" . }}
key: postgres-password
command:
- sh
- -c
- |
set -e
for f in $(ls /migrations/*.sql | sort); do
echo ">>> Applying $f"
psql -v ON_ERROR_STOP=1 -f "$f"
done
echo ">>> All migrations applied"
volumeMounts:
- name: migrations
mountPath: /migrations
volumes:
- name: migrations
configMap:
name: {{ include "cloudhost-platform.fullname" . }}-migrations
{{- end }}