ArgoCD implements GitOps for Kubernetes — continuously syncing cluster state to match what's declared in a Git repository. This guide covers setting up ArgoCD for automated, Git-driven deployments.
How This Relates to General GitOps Concepts
See GitOps Basics: Managing Infrastructure Through Git for the underlying principles — ArgoCD is a mature, purpose-built implementation of GitOps specifically for Kubernetes, handling the continuous reconciliation between your Git repository's declared state and your cluster's actual running state.
Step 1 — Install ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Step 2 — Access the ArgoCD UI
kubectl port-forward svc/argocd-server -n argocd 8080:443
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d
Step 3 — Define an Application Pointing to Your Git Repository
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/yourorg/k8s-manifests.git
targetRevision: main
path: myapp
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
Points ArgoCD at your Git repository containing Kubernetes manifests — selfHeal: true means ArgoCD automatically corrects any manual drift from the declared state, and prune: true removes resources no longer present in Git.
Step 4 — Trigger a Sync
argocd app sync myapp
With automated sync policy enabled, ArgoCD applies this automatically on detecting Git changes; manual sync is also available for controlled, deliberate deployment timing if you prefer not to fully automate.
The Deployment Workflow with ArgoCD
- Developer commits application code changes, CI builds and pushes a new container image
- A separate step (manual or automated) updates the image tag in your Kubernetes manifests repository
- ArgoCD detects the Git change and automatically syncs the cluster to match
Separating Application Code Repository from Manifests Repository
A common GitOps pattern: your application source code lives in one repository, while Kubernetes manifests (referencing specific image tags) live in a separate repository — keeps deployment configuration changes cleanly separated from application code changes.
Setting Up Automated Image Tag Updates
Consider tooling (ArgoCD Image Updater, or a CI step that commits manifest changes) to automatically update image tags in your manifests repository when new images are built — completes the automation loop from code commit to deployed change.
Monitoring Sync Status and Health
argocd app get myapp
ArgoCD tracks both sync status (does cluster state match Git) and health status (are the deployed resources actually healthy) — both matter; a synced but unhealthy application still needs attention.
Rolling Back with ArgoCD
argocd app rollback myapp
Since deployment history is tied to Git history, rollback is naturally supported — either through ArgoCD's own rollback command, or simply reverting the relevant Git commit and letting ArgoCD sync the reverted state.
Common Errors
ArgoCD shows "OutOfSync" but won't auto-correct — verify selfHeal is genuinely enabled if you expect automatic correction of manual drift; without it, ArgoCD detects drift but waits for manual sync approval rather than auto-correcting.
Continue Reading
- GitOps Basics: Managing Infrastructure Through Git
- How to Set Up Rolling Updates and Rollbacks in Kubernetes
- How to Build a Simple CI/CD Pipeline with GitHub Actions
Browse more articles in Kubernetes & Container Orchestration.