ArgoCD

Sync Waves & Hooks

29 question(s)

How do you run post-deployment smoke tests and fail the sync if they fail?

Advanced
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.
kind: Job
metadata:
  annotations:
    argocd.argoproj.io/hook: PostSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
Real-world example A PostSync test Job failing marks the sync failed and pages on-call, flagging the release as broken.

Common follow-ups: What signals a failed PostSync hook? | How do SyncFail hooks complement this?

Applications Sync & Health Sync Waves & Hooks

How are hook resources named and prevented from clashing across syncs?

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

Common follow-ups: Why do fixed-name Jobs cause conflicts? | What does BeforeHookCreation prevent?

Applications Sync & Health Sync Waves & Hooks

Which resource types are commonly used as hooks?

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

Common follow-ups: Why are Jobs ideal for hooks? | Can any resource be a hook?

Applications Sync & Health Sync Waves & Hooks

How do you coordinate hooks across multiple Applications (e.g., App of Apps)?

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

Common follow-ups: Do waves span multiple Applications? | How do you order child apps?

App of Apps Applications Sync Waves & Hooks

How do you annotate a resource with a sync wave?

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

Common follow-ups: What is the default wave? | Do negative waves run first?

Applications Sync & Health Sync Waves & Hooks

How long does ArgoCD wait between sync waves?

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

Common follow-ups: What if a wave never becomes Healthy? | Is the inter-wave delay configurable?

Sync & Health Applications Sync Waves & Hooks

What is a PreSync hook typically used for?

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

Common follow-ups: What happens if PreSync fails? | Why run migrations in PreSync?

Applications Sync & Health Sync Waves & Hooks

What is a PostSync hook typically used for?

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

Common follow-ups: When does PostSync run relative to health? | What does a PostSync failure indicate?

Applications Sync & Health Sync Waves & Hooks

What is a SyncFail hook and how is it used?

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

Common follow-ups: When does SyncFail run? | What tasks suit SyncFail?

Applications Sync & Health Sync Waves & Hooks

What are the hook deletion policy options?

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

Common follow-ups: Why use BeforeHookCreation? | What happens with no delete policy?

Applications Sync & Health Sync Waves & Hooks