Configure the Job's own backoffLimit and restartPolicy for pod-level retries, and ArgoCD's sync retry (syncPolicy.retry) to re-run the operation. Combine with BeforeHookCreation so each retry starts a fresh Job rather than colliding with the failed one.
Yes—hooks honor the sync-wave annotation within their phase, so multiple PreSync hooks can be ordered (e.g., provision in wave -2, migrate in wave -1). This gives fine control over multi-step preparation or teardown sequences inside a single sync.
When pruning, ArgoCD reverses wave order—higher waves are deleted before lower ones—so dependents are removed before their dependencies (mirroring creation order). This prevents deleting a prerequisite while something still depends on it.
Real-world example
On teardown, the frontend (wave 2) is pruned before the database (wave 1), the reverse of deployment order.
Likely follow-ups
Why reverse order for deletion? | How does this protect dependencies?
Run-to-completion resources like Jobs are ideal because ArgoCD tracks their success/failure to gate the sync. Pods can work for simple tasks, but Jobs give retries, completions, and clean semantics for migrations, tests, and one-off tasks.
Real-world example
Migrations and smoke tests are Jobs so ArgoCD can wait for completion and detect failure.
Likely follow-ups
Why not use a Deployment as a hook? | What do Jobs provide over bare Pods?
Hooks run each time a sync applies them. To force a hook (like tests) to run every sync even without changes, ensure the resource differs (e.g., generateName or a changing annotation) or trigger a sync explicitly. For run-once semantics, use appropriate delete policies and stable naming.
metadata:
generateName: smoke-test-
Real-world example
Using generateName makes a fresh smoke-test Job on every sync rather than skipping an unchanged one.
Likely follow-ups
How do you force a hook to rerun? | What gives run-once behavior?
Add a PostSync hook Job that calls the external system (webhook, deployment tracker, ChatOps). Because it runs only after resources are Healthy, it reliably signals a completed deployment. Alternatively, use the Notifications controller for event-driven alerts without a hook.
Too many waves/hooks slow syncs (each wave waits for health), complicate debugging, and can hide ordering assumptions. Long-running or flaky hooks stall deployments. Keep ordering minimal, make hooks fast and idempotent, and prefer proper readiness/health over artificial waits.
Real-world example
A team collapses excessive waves after syncs became slow, keeping only the essential CRD-before-workload ordering.
Likely follow-ups
Why can many waves slow syncs? | How do you keep hooks reliable?
The Sync phase is the main phase where the application's regular resources are applied. Sync-phase hooks run alongside these resources. PreSync runs before this phase and PostSync after it completes and is Healthy.
Real-world example
The Deployment and Service apply during the Sync phase, between the PreSync migration and PostSync tests.
Likely follow-ups
What runs in the Sync phase? | How does it relate to Pre/PostSync?
Use a PreSync or Sync hook Job with BeforeHookCreation deletion and idempotent seeding logic, or gate it so re-runs are no-ops. Because hooks run each sync, the seed script itself should detect existing data and skip, giving effectively run-once behavior safely.