ArgoCD
ArgoCD is a declarative GitOps tool that continuously compares a Git repository with a Kubernetes cluster and syncs the cluster to match, correcting any drift it finds.
Understanding ArgoCD
What Is ArgoCD and How Does It Work
ArgoCD is a Kubernetes controller that implements GitOps continuous delivery. You describe the desired state of your application in Git, and ArgoCD keeps asking one question: does the live cluster match Git? If not, it marks the application OutOfSync and, depending on policy, applies the difference for you.
This pull model means your CI system never needs credentials to the cluster. Engineers deploy by merging a commit to the config repository, and the Git history becomes the audit trail of who changed what and when.
The Reconciliation Loop
ArgoCD polls Git about every three minutes by default. A webhook from GitHub or GitLab makes it react within seconds. Two separate statuses matter: sync status (does the cluster match Git?) and health status (are the resources actually working?).
Application Manifest Example
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata: name: payment-api namespace: argocdspec: project: payments source: repoURL: https://github.com/razorpay/k8s-configs targetRevision: main path: apps/payment-api/production destination: server: https://kubernetes.default.svc namespace: payment-api-production syncPolicy: automated: prune: true # delete resources removed from Git selfHeal: true # revert manual kubectl changes syncOptions: - CreateNamespace=trueKey CLI Commands
# Create the install namespace and install ArgoCDkubectl create namespace argocdkubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml # Inspect and compareargocd app get payment-apiargocd app diff payment-api # Sync manuallyargocd app sync payment-api # Roll back (auto-sync must be disabled first)argocd app history payment-apiargocd app rollback payment-api 12Patterns Worth Knowing
- App of Apps: one root Application watches a folder of other Application manifests, so adding a service means adding one YAML file.
- ApplicationSet: generates many Applications from a template, for example one per cluster or per environment folder.
- AppProject: restricts which repos, clusters, and namespaces a team may deploy to.
Troubleshooting
| Symptom | Check | What to Look For |
|---|---|---|
| Stuck OutOfSync | argocd app diff |
Fields mutated by controllers, needs ignoreDifferences |
| Sync fails | argocd app get --show-operation |
Validation or permission error message |
| Manual fix keeps reverting | Sync policy | selfHeal is working as designed |
| Degraded health | Pod events and logs | Failing probes or image pull errors |
TipUse
argocd app diffbefore enabling auto-sync on a production app. It shows exactly what ArgoCD would change on the first sync.
RememberWith selfHeal on, direct kubectl edits are reverted. Change Git first, even in an emergency, or pause auto-sync on that application while you work.
SecurityUse AppProjects and RBAC to limit who can sync and where an Application may deploy. ArgoCD's service account holds broad cluster permissions, so write access to the config repo is effectively cluster access.
Common MistakeKeeping application code and Kubernetes manifests in one repository. Every code commit then triggers a refresh and image-tag bumps pollute app history. Use a separate config repo.
Frequently Asked Questions
What does GitOps mean in the context of ArgoCD?
Git is the single source of truth for what runs in the cluster. You commit desired manifests, and ArgoCD reconciles the live state to match. If someone edits the cluster directly, ArgoCD detects the drift and can revert it.
Why does argocd app rollback fail on my application?
Rollback is not allowed while automated sync is enabled, because the next reconcile would immediately re-apply Git. Disable auto-sync first, or better, revert the commit in Git so the fix is recorded and applied automatically.
ArgoCD or Flux, which should I choose?
Both implement pull-based GitOps. ArgoCD offers a rich web UI, multi-cluster management, and ApplicationSets, which many teams find easier to adopt. Flux is a set of lightweight controllers that suits teams wanting a fully CLI and CRD driven workflow.