kind: Job
metadata:
annotations:
argocd.argoproj.io/hook: PostSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
ArgoCD
Topics in this category
ArgoCD
Sync Waves & Hooks
Add a PostSync hook Job that runs the tests; if the Job fails, the sync is marked failed, signaling a bad deployment (and triggering SyncFail hooks/notifications). Combined with automated rollback strategies or alerting, this gates the deployment on test success within the GitOps flow.
Real-world example
A PostSync test Job failing marks the sync failed and pages on-call, flagging the release as broken.
Applications
Sync & Health
Sync Waves & Hooks
Hooks are typically generated with unique names (e.g., using generateName) or cleaned up via BeforeHookCreation so a new sync doesn't collide with a leftover from a prior run. Because Jobs are immutable in key fields, reusing a fixed name without deletion causes apply errors, so deletion policies or unique names are important.
metadata:
generateName: migrate-
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
Real-world example
Each sync's migration Job gets a unique generated name, avoiding conflicts with the previous run's Job.
Applications
Sync & Health
Sync Waves & Hooks
Jobs are the most common (run to completion for migrations, tests, seeds), and Pods for simple one-off tasks. Any Kubernetes resource can technically carry hook annotations, but run-to-completion workloads (Jobs) fit hook semantics best because ArgoCD tracks their success/failure to gate the sync.
Real-world example
Migrations, backups, and smoke tests are all implemented as hook Jobs that ArgoCD monitors to completion.
Applications
Sync & Health
Sync Waves & Hooks
Ordering across separate Applications isn't governed by a single sync's waves/hooks; you coordinate via the parent (App of Apps) sync waves on the child Application resources, or by splitting concerns so prerequisites are their own app synced first. Within one app, waves/hooks order resources; across apps, order the Application CRs themselves.
# Parent app annotates child Applications with sync-wave to order them
Real-world example
The parent app syncs the 'infra' child Application (wave 0) before the 'workloads' child (wave 1) so shared CRDs exist first.
App of Apps
Applications
Sync Waves & Hooks
Add the annotation argocd.argoproj.io/sync-wave with an integer string value on the resource metadata. Lower numbers apply first. Resources without the annotation default to wave 0.
metadata:
annotations:
argocd.argoproj.io/sync-wave: "2"
Real-world example
The frontend is annotated wave 2 so it deploys after the backend in wave 1.
Applications
Sync & Health
Sync Waves & Hooks
After applying a wave, ArgoCD waits for those resources to become Healthy before starting the next wave, subject to timeouts. There's also a short delay (configurable) between waves. If a wave's resources never become Healthy, later waves won't proceed and the sync stalls.
Real-world example
The next wave doesn't start until the database in the current wave reports Healthy.
Sync & Health
Applications
Sync Waves & Hooks
PreSync hooks run before the main resources apply, ideal for preparation tasks that must succeed first: database schema migrations, provisioning, or backups. If a PreSync hook fails, the sync fails and the new version isn't rolled out.
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
Real-world example
A backup Job runs as a PreSync hook so there's a restore point before the deployment proceeds.
Applications
Sync & Health
Sync Waves & Hooks
PostSync hooks run after all resources are applied and Healthy—used for smoke tests, cache warming, notifications, or registering the deployment. A failing PostSync hook marks the sync failed, signaling the release didn't pass its post-checks.
metadata:
annotations:
argocd.argoproj.io/hook: PostSync
Real-world example
A PostSync integration-test Job verifies the new version works end-to-end after deployment.
Applications
Sync & Health
Sync Waves & Hooks
A SyncFail hook runs only when a sync operation fails, used for cleanup, rollback of partial changes, or alerting. It lets you react to failed deployments within the sync lifecycle rather than relying solely on external monitoring.
metadata:
annotations:
argocd.argoproj.io/hook: SyncFail
Real-world example
On a failed sync, a SyncFail hook cleans up temporary resources and posts an alert to the incident channel.
Applications
Sync & Health
Sync Waves & Hooks
The hook-delete-policy annotation accepts HookSucceeded (delete after success), HookFailed (delete after failure), and BeforeHookCreation (delete the prior hook before creating a new one). They keep completed hook resources from accumulating and manage reruns.
metadata:
annotations:
argocd.argoproj.io/hook-delete-policy: HookSucceeded
Real-world example
Successful migration Jobs are auto-deleted so old completed Jobs don't clutter the namespace.
Applications
Sync & Health
Sync Waves & Hooks