How would you run a database migration with Argo CD?
IntermediateConceptSync Waves, Hooks, Health & Diffing
Answer
As a PreSync hook Job that uses the new image:
metadata:
name: api-migrate
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
spec:
backoffLimit: 1
activeDeadlineSeconds: 600
If it fails, the sync stops and the old version keeps running. Migrations must be backward compatible (expand/contract) because old pods run against the new schema during the rollout. For the very first install, the database itself must already exist (separate app or earlier sync).