You've learned how to manage sync policies in Chapter 9. Now you face a critical challenge: deployment order matters. Your PostgreSQL database migration must run before your FastAPI application deploys. Your health checks must pass before marking the deployment as healthy. Your rollback must run cleanup jobs when deployment fails.
This is where sync waves and resource hooks solve real problems. Waves order resource creation sequentially. Hooks define what happens at critical sync points: before, during, and after deployment.
Consider this scenario. You're deploying version 2 of your agent with a database schema change:
Without hooks, your application fails because migrations never ran. With hooks:
The difference is simple: waves group resources by creation order. Hooks define executable steps around those waves.
A sync wave is an annotation that tells ArgoCD: "Create this resource in this order, then move to the next wave."
Waves execute in ascending numerical order:
Key principle: ArgoCD waits for each wave to fully sync and stabilize before moving to the next wave. A resource in wave 1 cannot start until all wave 0 resources are healthy.
The annotation syntax is simple:
Example: ConfigMap and Secret in Wave 0
Output:
Example: Deployment in Wave 1
Output:
A resource hook is a Kubernetes Job or Pod that runs at specific points in the sync lifecycle. Unlike regular resources, hooks don't stay running—they execute and exit.
After a hook finishes, what happens to the Job/Pod?
A PreSync hook runs before any resources sync. This is where you run database migrations.
Output (on successful migration):
Output (on migration failure):
A PostSync hook runs after sync completes successfully. Use this for:
Output:
A SyncFail hook runs when the sync process fails. Use this for alerting and rollback notifications.
Output (when sync fails):
Deletes the Job immediately after it succeeds. Use this for database migrations and one-time setup jobs.
Deletes the Job only if it fails. If it succeeds, the Job persists. Use this to keep successful runs for audit trails.
Deletes the previous hook instance before creating a new one. Use this for notification hooks that run on every sync.
Here's a realistic example combining waves and hooks:
Output (complete sync with waves):
When hooks fail, ArgoCD stops the sync. Here's how to diagnose:
Output:
You built a gitops-deployment skill in Chapter 0. Test and improve it based on what you learned.
Ask yourself:
If you found gaps: