Ravindra BagaleCourses & study guides मराठी

Chapter 86: Argo CD (GitOps)

DevOps

86.8 Diff, sync waves and hooks

Story. Before syncing prod, Sara at a Microsoft-style team always ran argocd app diff. She saw a Service change she did not expect and fixed the PR. For a database migration Job that must finish before the new Deployment, they used a PreSync hook and sync waves so order stayed correct.

Diff shows changes. Sync waves and hooks order how objects apply during sync.
Diff shows changes. Sync waves and hooks order how objects apply during sync.

Why

Blind sync is how Friday nights break. Diff shows the plan. Waves and hooks control order.

What

  • argocd app diff — Live versus desired.
  • Sync wave — Annotation argocd.argoproj.io/sync-wave: "1" (lower waves first).
  • Hooks — Annotations such as PreSync, PostSync, SyncFail on Jobs or Pods.
  • Hook delete policies — When hook resources are removed after success or failure.

How

  1. Run diff before every important sync.
  2. Put migrations in a PreSync Job when needed.
  3. Give foundation objects wave 0, apps wave 1, and so on.
  4. Read hook logs when sync hangs.

Example 1: Diff before sync

argocd app diff shop-api

Output

===== apps/Deployment shop/shop-api ======
...
-  replicas: 3
+  replicas: 4

What it shows: Git wants 4 replicas; live still has 3. You decide if that is expected.

Example 2: Sync-wave annotation

metadata:
  name: shop-config
  annotations:
    argocd.argoproj.io/sync-wave: "0"
metadata:
  name: shop-api
  annotations:
    argocd.argoproj.io/sync-wave: "1"

What it shows: ConfigMap-like objects in wave 0 apply before the Deployment in wave 1.

Ravindra Bagale's Tip

If sync is stuck, look for a PreSync Job that never completed — hooks block the wave.

Quick quiz

Q1. What does argocd app diff show?

The difference between live state and desired Git state.

Q2. Which sync wave runs first?

Lower numbers run first (for example 0 before 1).

Q3. What is a PreSync hook for?

Work that must finish before the main sync apply, such as a migration Job.

Did you understand? Let us try it once more.