Interview Prep/GitOps & Argo CD/Sync Waves, Hooks, Health & Diffing

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).

All GitOps & Argo CD questions Roadmap: Argo CD (GitOps)

More on Sync Waves, Hooks, Health & Diffing