Skip to content

Syncing applications with Argo CD: CAPA practice questions

A sync applies the target state from Git to the cluster. It can be started by hand from the UI or with argocd app sync, or automatically by a sync policy.

By Ibrahim Yesilay · Published · Updated

Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.

What Syncing applications with Argo CD covers in CAPA

A sync applies the target state from Git to the cluster. It can be started by hand from the UI or with argocd app sync, or automatically by a sync policy. A manual sync can be narrowed: --resource limits it to chosen resources, which is called a selective sync, --revision syncs a specific commit or tag, --prune allows the deletion of resources that are no longer in Git, and --dry-run previews the apply without changing the cluster. Hooks do not run during a selective sync.

Automated sync is turned on under spec.syncPolicy.automated. It only acts when the application is OutOfSync and it is cautious by default. prune is off, so a resource deleted from Git stays in the cluster until pruning is allowed. selfHeal is off, so a change made directly in the cluster does not trigger a new sync. allowEmpty must be set before automated pruning may remove every resource of an application. A retry block adds a limit and an exponential backoff for failed sync attempts. An application that syncs automatically cannot be rolled back with argocd app rollback; automated sync has to be disabled first.

Sync options change how resources are applied, either for the whole application under syncPolicy.syncOptions or for one resource with the argocd.argoproj.io/sync-options annotation. CreateNamespace=true creates the destination namespace, PruneLast=true prunes at the end of the sync, ApplyOutOfSyncOnly=true skips resources that already match, ServerSideApply=true uses server-side apply, Replace=true uses replace instead of apply and can be destructive, and Prune=false protects one resource from pruning.

Ordering is controlled by phases and waves. The argocd.argoproj.io/hook annotation places a resource in the PreSync, Sync, PostSync, SyncFail or PostDelete phase, and a PreSync hook that fails stops the whole sync. Within a phase, the argocd.argoproj.io/sync-wave annotation orders resources from the lowest number up; the default wave is 0, so a negative wave runs earlier. Pruning runs in reverse wave order. A hook-delete-policy of HookSucceeded, HookFailed or BeforeHookCreation, the assumed default, decides when hook resources are removed. Sync windows on an AppProject can allow or deny syncs on a cron schedule, and a deny window wins over an allow window.

Key points

  • Automated sync does not prune or self-heal until prune and selfHeal are enabled.
  • Waves apply from the lowest number up, with 0 as the default; pruning runs in reverse.
  • A failed PreSync hook stops the sync before the main resources are applied.
  • An application with automated sync cannot be rolled back until automation is turned off.

Three sample questions

14 CAPA questions on Syncing applications with Argo CD, 14 with explanations. How practice works

Question 1

Which of the following is NOT a valid sync option in Argo CD?
  1. A.CreateNamespace
  2. B.PruneLast
  3. C.ServerSideApply
  4. D.AutoHeal

Correct answer: D

CreateNamespace, PruneLast and ServerSideApply are documented sync options (set as Name=true). There is no AutoHeal sync option; healing drift is the selfHeal setting of the automated sync policy. Why the other options are wrong. CreateNamespace, PruneLast and ServerSideApply are all listed on the Sync Options page.

Sources: Argo CD docs: Sync Options, Argo CD docs: Automated Sync Policy

Question 2

Which command syncs an application and skips hooks?
  1. A.argocd app sync --strategy apply
  2. B.argocd app sync --skip-hooks
  3. C.argocd app sync --force
  4. D.argocd app sync --ignore-hooks=true

Correct answer: A

argocd app sync takes --strategy with the values apply or hook. The hook strategy, the default, submits the resources so that the sync takes their hook annotations into account, while the apply strategy simply runs kubectl apply on the manifests, so choosing apply runs the sync without that hook handling. Why the other options are wrong. "argocd app sync --skip-hooks": the sync command has no such flag. "argocd app sync --force": --force makes the sync a force apply (a resource is deleted only when a patch still conflicts after five retries); with the default hook strategy the hooks still run. "argocd app sync --ignore-hooks=true": no such flag exists either.

Sources: Argo CD docs: argocd app sync Command Reference, Argo CD docs: Sync Applications with Kubectl (Apply and Hook synchronization strategies)

Question 3

What is the purpose of the argocd.argoproj.io/sync-wave annotation?
  1. A.To specify how many times a failed sync operation is retried before the application is marked as failed
  2. B.To control the order in which resources are synced
  3. C.To group resources for batch operations
  4. D.To define how often automated sync checks the Git repository for new commits

Correct answer: B

The sync-wave annotation takes an integer, and Argo CD applies resources from the lowest wave to the highest (the default is 0, negatives are allowed). That lets you create prerequisites first. Why the other options are wrong. "To specify how many times a failed sync operation is re...": the number of attempts is set by the retry block with limit in the sync policy, not by waves. "To group resources for batch operations": a wave value is an ordering number for resources, it does not act as a handle for batch operations. "To define how often automated sync checks the Git repos...": automated sync is configured under syncPolicy.automated, and the annotation only holds an ordering integer.

Sources: Argo CD docs: Sync Phases and Waves, Argo CD docs: Automated Sync Policy

Practice this topic

Focus mode keeps every question on Syncing applications with Argo CD until you leave it. 10 free guest answers, then a free account; no credit card.

Or open CAPA practice across all topics.

Sources

The explanation above was checked against these official documents.