- Ensure a DB migration runs before application Deployments.
- Run notifications or cleanup only after a successful sync.
- Control whether hook resources are retained or removed.
For more details see the Argo CD hooks docs:
- https://argo-cd.readthedocs.io/en/stable/user-guide/hooks/
- https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/

- Purpose: run a migration before any application resources are created.
- Desired lifecycle: the job should be removed after it succeeds.
- Purpose: send a notification after a successful sync.
- Recommended cleanup: delete after success so notifications don’t persist.

- Purpose: run remedial cleanup when a sync completes (e.g., remove temp resources).
- Example policy: delete only on failure to preserve artifacts for troubleshooting.

Hook phases act like guardrails: a PreSync hook must succeed before Sync proceeds; a failing PreSync stops the synchronization and prevents deployments.
- Happy path: PreSync → Sync → PostSync
- If Sync fails, PostSync is typically not executed unless you configure alternative lifecycle behaviors.


- Argo CD creates the PreSync DB migration Job (hook icon shown).
- Argo CD waits for the Job to finish successfully.
- If the Job succeeds, Argo CD proceeds to create normal resources (Deployment, Service, etc.) — the Sync phase.
- If the Sync succeeds, PostSync hooks (cleanup, notifications) execute as configured.
- hook-delete-policy determines whether Jobs remain after success/failure.
- The migration job was created and completed.
- Deployments were created in the Sync phase.
- A cleanup job ran afterwards and, due to the delete policy, the DB migration job was deleted.

Summary
- Use
argocd.argoproj.io/hook: PreSyncto force jobs to run before your main sync. - Use
argocd.argoproj.io/hook: PostSyncfor notifications/cleanup after successful syncs. - Use
argocd.argoproj.io/hook-delete-policyto control retention of hook resources. - Optionally use
argocd.argoproj.io/sync-wavefor finer-grained numeric ordering across many resources.
- Argo CD Hooks — https://argo-cd.readthedocs.io/en/stable/user-guide/hooks/
- Argo CD Sync Waves — https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/
- Argo CD CLI docs — https://argo-cd.readthedocs.io/en/stable/user-guide/commands/