metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
ArgoCD
Topics in this category
ArgoCD
Sync Waves & Hooks
Sync waves control the order in which resources are applied during a sync. Each resource can carry an annotation `argocd.argoproj.io/sync-wave` with an integer; ArgoCD applies lower waves first and waits for each wave's resources to become Healthy before the next. This orders dependencies like namespaces, CRDs, databases, then apps.
Real-world example
Namespaces and CRDs are placed in wave 0, the database in wave 1, and the app in wave 2 so dependencies come up in order.
Applications
Sync & Health
Sync Waves & Hooks
The default wave is 0 when no annotation is set. Negative waves run before wave 0, which is handy for prerequisites like CRDs, namespaces, or operators that must exist before everything else. Ordering runs from the lowest (most negative) to the highest wave.
metadata:
annotations:
argocd.argoproj.io/sync-wave: "-1" # CRDs before workloads
Real-world example
CRDs are annotated wave -1 so they install before any custom resources in the default wave 0.
Applications
Sync & Health
Sync Waves & Hooks
Hooks are resources (usually Jobs or Pods) that run at specific points in a sync to perform tasks like migrations, tests, or notifications. They're marked with `argocd.argoproj.io/hook` and a phase (PreSync, Sync, PostSync, SyncFail, Skip). ArgoCD runs them at the right time and tracks their success as part of the sync.
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
Real-world example
A PreSync Job runs database migrations before the new application version is deployed.
Applications
Sync & Health
Sync Waves & Hooks
PreSync runs before the main sync (e.g., DB migration). Sync runs alongside the normal resources. PostSync runs after all resources are applied and Healthy (e.g., smoke tests, notifications). SyncFail runs if the sync fails (cleanup/alert). Skip means don't apply the resource. Phases let you inject logic around the deployment.
metadata:
annotations:
argocd.argoproj.io/hook: PostSync # smoke tests after deploy
Real-world example
A PostSync hook runs integration smoke tests only after the app is deployed and healthy; a SyncFail hook alerts on failure.
Applications
Sync & Health
Sync Waves & Hooks
Hooks also honor sync waves, so you can order hooks relative to each other and to resources. Within a phase, waves determine order. PreSync hooks run (in wave order) before Sync-phase resources; PostSync hooks run after all Sync resources are Healthy. This lets you build precise ordered pipelines within a single sync.
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/sync-wave: "-2"
Real-world example
Two PreSync hooks run in wave order—first provisioning, then migration—before the app resources apply.
Applications
Sync & Health
Sync Waves & Hooks
Hook deletion policies control when hook resources (like Jobs) are cleaned up: HookSucceeded (delete after success), HookFailed (delete after failure), or BeforeHookCreation (delete the previous hook instance before creating a new one). They prevent accumulation of completed Job objects and manage reruns.
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
Real-world example
A migration Job is deleted automatically after it succeeds so old completed Jobs don't pile up in the namespace.
Applications
Sync & Health
Sync Waves & Hooks
Use a PreSync hook Job that runs the migration; ArgoCD waits for it to complete successfully before applying the new app version (in a later phase/wave). If the migration fails, the sync fails and the new version isn't rolled out, protecting against deploying code against an unmigrated schema.
kind: Job
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
Real-world example
The schema migration runs as a PreSync Job; only after it succeeds does the new app image get deployed.
Applications
Sync & Health
Sync Waves & Hooks
Sync waves order the ongoing desired-state resources that ArgoCD keeps reconciled. Hooks are transient, run per-sync (often deleted afterward), and tie to phases/failure—ideal for imperative one-off tasks like migrations or tests. Use waves for ordering persistent resources; use hooks for actions that should run around a sync but not be permanently managed.
Real-world example
Persistent components use waves for ordering, while a one-time cache warm-up runs as a PostSync hook that's deleted after success.
Applications
GitOps Principles
Sync Waves & Hooks
Assign ascending waves by dependency: namespaces/CRDs (wave -1/0), configuration and secrets (wave 0), stateful backends like databases (wave 1) with a readiness gate, then backend services (wave 2), then frontends (wave 3). ArgoCD waits for each wave to be Healthy, ensuring dependencies are ready before dependents deploy.
# db: sync-wave "1"; api: sync-wave "2"; web: sync-wave "3"
Real-world example
The database (wave 1) must be Healthy before the API (wave 2), which must be up before the web tier (wave 3).
Applications
Sync & Health
Sync Waves & Hooks
A resource annotated with hook Skip is not applied by ArgoCD during sync—useful to keep a manifest in the repo for reference or manual application without ArgoCD managing it. It effectively excludes the resource from the sync while keeping it version-controlled.
metadata:
annotations:
argocd.argoproj.io/hook: Skip
Real-world example
A sample/manual resource is kept in Git for documentation but marked Skip so ArgoCD never applies it.
Applications
GitOps Principles
Sync Waves & Hooks