ProdCraft
Subscribe
GitOps

Argo CD Drift Detection: Diagnose OutOfSync Without Blindly Syncing

Diagnose Argo CD OutOfSync states, compare live and desired manifests, handle ignored fields and sync safely with rollback planning.

ProdCraft5 min read
Software team collaborating around a laptop during a CI CD deployment and workflow permissions review

Argo CD continuously compares the desired Kubernetes state in Git with the live cluster. An OutOfSync application is a signal that the two representations differ; it is not automatically proof that a deployment is broken. The difference may be a real configuration drift, a controller-managed field, a mutating webhook or a manifest rendering problem.

Start with the diff

Inspect the resource and field that differ. Confirm the Git revision, target namespace, destination cluster and rendered manifests. If a Helm chart or Kustomize overlay is involved, reproduce the render locally using the same values and versions as the controller.

Separate intended from accidental changes

Some controllers update fields such as replica counts, status or generated annotations. Other differences indicate a manual hotfix or an untracked configuration change. Do not add broad ignore rules to make the status green; that can hide meaningful drift. Ignore only fields with a documented owner and reason.

Check ownership conflicts

Server-side apply, field managers and other operators can compete for the same fields. Inspect managed fields and the controller that owns the resource. A GitOps tool should not continually overwrite a field that another controller is expected to manage.

Sync in a controlled way

  1. Review the complete diff, including dependent resources.
  2. Confirm the change is present in the intended Git commit.
  3. Use a staging environment or canary where possible.
  4. Sync the smallest safe resource set.
  5. Verify health checks and application behavior.
  6. Revert the Git commit if the desired state is wrong.

Prevent recurring drift

Restrict manual production edits, use pull requests for configuration changes, and document emergency break-glass procedures. Alert on persistent OutOfSync state rather than every short-lived reconciliation. Keep application health and sync status as separate signals.

Useful companion guides include installing Argo CD, safe Helm releases and Kubernetes rolling updates.

Engineering considerations

Start with the exact resource diff and identify whether the changed field belongs to spec, metadata or status. Confirm the source revision, destination cluster and rendering parameters used by Argo CD. A Helm value changed outside Git, a chart version mismatch or a Kustomize patch applied to the wrong overlay can create a valid but unexpected manifest. Save the rendered desired output for comparison and do not sync until the source of the difference is understood.

Implementation details

Kubernetes controllers routinely modify resources after creation. Autoscalers can change replicas, certificate controllers update status and service meshes inject annotations or sidecars. Server-side apply tracks field managers and can reveal ownership conflicts. Configure narrowly scoped ignoreDifferences rules only when a field is intentionally managed elsewhere. Broadly ignoring spec fields can conceal a manual security change or a real configuration drift.

Security and reliability controls

Protect Git as the source of truth with pull requests, required reviews and branch protection for production manifests. Restrict who can change Argo CD destinations, sync policies and repository credentials. Emergency manual edits should be documented and reconciled into Git promptly. If live state must temporarily differ, record an owner, reason and expiry date. A permanent set of undocumented exceptions turns GitOps into a misleading dashboard.

Testing strategy

Some resources depend on others: CRDs must exist before custom resources, secrets before workloads and database migrations before application rollout. Use sync waves or hooks carefully and make hooks idempotent. Configure health checks so the controller does not mark a deployment healthy merely because a pod object exists. Verify readiness, service endpoints and application-level smoke tests after synchronization.

Operational monitoring

Pruning removes live resources that are no longer in desired state. This is useful for cleanup but dangerous when a manifest is accidentally removed or a generator returns an incomplete set. Review pruning in the diff, protect critical resources with suitable policies and test deletion in staging. For stateful resources, understand reclaim policies and finalizers before enabling automated deletion. A green sync status is not worth losing a production database.

Failure diagnosis

Keep secret material out of Git unless it is encrypted with a deliberate secret-management workflow. Limit repository credentials to required repositories and use short-lived tokens where supported. Rotate credentials and test controller access after rotation. Restrict who can create Applications that point to privileged namespaces or clusters. Multi-tenant Argo CD installations need clear project boundaries and destination restrictions.

Rollout and maintenance

Alert on persistent OutOfSync state, repeated sync failures and unhealthy resources, but suppress noisy transient changes during known rollouts. During an incident, capture the diff, controller logs, source commit and live state before changing anything. Roll back through Git where possible so desired state remains auditable. After recovery, add a regression test or policy check that would have caught the configuration error earlier.

Operational handover

Before handing this capability to an operations team, document the configuration owner, supported versions, dependency map and escalation path. Include the commands or dashboard views needed to verify normal operation, along with the expected values and known limitations. Store configuration in version control, review changes through the normal deployment process and keep a tested rollback procedure. Schedule periodic reviews because upstream components, security requirements and workload patterns change. A short runbook should explain how to identify a failed component, what evidence to collect, which actions are safe to retry and when to escalate. Test that runbook during a maintenance exercise rather than waiting for an outage. Finally, measure the result against a baseline: reliability improvements should be visible in error rates, latency, resource consumption, recovery time or reduced manual work. This makes the implementation maintainable after the original developer has moved to another project.

Example drift investigation

Suppose a Deployment is OutOfSync because its replica count differs from Git. First check whether a HorizontalPodAutoscaler owns that field. If so, document the ownership and configure a narrow ignore rule rather than repeatedly forcing the Git value. If the difference is an image tag changed manually during an incident, identify the operator and incident record, then decide whether to revert the live change or commit the intended version through review. Check managed fields and audit events to determine how the live value changed. After reconciliation, verify rollout status, pod readiness and application health. This example shows why the correct response depends on field ownership and operational intent, not simply pressing Sync until the status becomes green.

Share this article

Written by

ProdCraft

ProdCraft publishes practical engineering guides on DevOps, Kubernetes, Docker, Linux, databases, cloud and LLMs — written for engineers who ship.

227 articles View profile

The weekly ops & AI brief

One email a week with the best new guides, tools and incident write-ups. No spam, unsubscribe anytime.

Leave a Reply

Your email address will not be published. Required fields are marked *