ArgoCD

Sync Waves & Hooks

29 question(s)

What are sync waves in ArgoCD?

Beginner
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.
metadata:
  annotations:
    argocd.argoproj.io/sync-wave: "1"
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.

Common follow-ups: What is the default wave? | How does ArgoCD wait between waves?

Applications Sync & Health Sync Waves & Hooks

What is the default sync wave and how are negative waves used?

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

Common follow-ups: Why put CRDs in a negative wave? | What order do waves run in?

Applications Sync & Health Sync Waves & Hooks

What are resource hooks in ArgoCD?

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

Common follow-ups: What resource types are used as hooks? | What phases exist?

Applications Sync & Health Sync Waves & Hooks

What are the hook phases and when does each run?

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

Common follow-ups: When does PostSync run relative to health? | What is the SyncFail phase for?

Applications Sync & Health Sync Waves & Hooks

How do sync waves and hooks interact?

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

Common follow-ups: Do hooks respect sync waves? | How do you order multiple hooks?

Applications Sync & Health Sync Waves & Hooks

What are hook deletion policies?

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

Common follow-ups: Why use BeforeHookCreation? | What happens without a delete policy?

Applications Sync & Health Sync Waves & Hooks

How do you run a database migration safely before deploying a new version?

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

Common follow-ups: What happens to the deploy if the migration fails? | Why PreSync rather than PostSync?

Applications Sync & Health Sync Waves & Hooks

How do hooks differ from plain resources with sync waves, and when do you choose each?

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

Common follow-ups: Why are hooks better for one-off tasks? | Are hooks part of the desired state?

Applications GitOps Principles Sync Waves & Hooks

How do you order a multi-tier application deployment with waves?

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

Common follow-ups: How does ArgoCD know a wave is done? | What if a wave never becomes Healthy?

Applications Sync & Health Sync Waves & Hooks

What is a Skip hook and when is it used?

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

Common follow-ups: How does Skip differ from Prune=false? | Why keep a skipped resource in Git?

Applications GitOps Principles Sync Waves & Hooks