Self-Heal and Prune Options
What you'll learn: How ArgoCD can automatically correct configuration drift and clean up orphaned resources to maintain your desired state.
The Problem: Drift and Orphans
Once you've deployed an application with ArgoCD, two common problems emerge:
- Drift: Someone manually modifies a resource in the cluster (bypassing Git), creating a mismatch between your Git source of truth and cluster reality.
- Orphaned Resources: You remove a resource from Git, but it remains running in the cluster, consuming resources and potentially causing conflicts.
ArgoCD's self-heal and prune options solve both problems automatically.
Self-Heal: Auto-Correcting Drift
Self-heal enables ArgoCD to automatically revert manual changes back to what's defined in Git. If someone kubectl edits a deployment to change replicas, self-heal detects the drift and restores the Git-defined value within seconds.
Think of it like a thermostat: if someone opens a window and the temperature drops, the heater kicks in automatically to restore your set temperature.
Enable self-heal in your Application resource:
spec:
syncPolicy:
automated:
selfHeal: true
Prune: Removing Orphaned Resources
Prune tells ArgoCD to delete resources from the cluster when they're removed from Git. Without pruning, deleting a Service definition from your repo leaves the Service running indefinitely.
Enable prune alongside self-heal:
spec:
syncPolicy:
automated:
selfHeal: true
prune: true
When to Use These Options
- Self-heal: Essential for production environments where Git is the single source of truth
- Prune: Use carefully—it will delete resources, so ensure your Git repo is complete
- Together, they create a truly declarative, self-maintaining system
Key Takeaway: Self-heal automatically corrects manual cluster changes, while prune removes resources deleted from Git—together they enforce Git as your authoritative source of truth and prevent configuration drift.