On this page
How to Set Up GitOps With Argo CD
A step-by-step tutorial to install Argo CD, connect it to a Git repo, and deploy an app declaratively — so Git becomes your source of truth.
Quick answer
- Argo CD is a Kubernetes-native GitOps tool: you point it at a Git repo, and it keeps the cluster matching the repo.
- You install it into the cluster, register a repository, and define an Application that references a path in Git.
- Success looks like Argo CD showing the app “Synced” and “Healthy,” and any Git change being applied automatically.
What you’ll build
An Argo CD deployment that watches a Git repository and keeps a Kubernetes application in sync with it. When you push a change to the repo, Argo CD applies it; when you drift the cluster by hand, Argo CD corrects it.
Step 1 — Install Argo CD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlHow to verify it worked: kubectl get pods -n argocd shows the Argo CD pods becoming Running. Then expose the UI:
kubectl port-forward svc/argocd-server -n argocd 8080:443Open https://localhost:8080. The initial admin password is the name of the argocd-initial-admin-secret pod — retrieve it with:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -dStep 2 — Prepare a Git repo
Create a repository with a hello/ directory containing the Deployment and Service from the Kubernetes deploy tutorial. Push it to GitHub or GitLab.
Step 3 — Register the repository
argocd repo add https://github.com/YOU/your-repo.gitFor a private repo, add credentials via argocd repo add flags or a secret. How to verify it worked: the command prints connection status success.
Step 4 — Create an Application
argocd app create hello \
--repo https://github.com/YOU/your-repo.git \
--path hello \
--dest-server https://kubernetes.default.svc \
--dest-namespace default \
--sync-policy automated \
--self-healThe --sync-policy automated makes Argo CD apply Git changes automatically, and --self-heal reverts manual drift.
Step 5 — Verify sync and self-healing
argocd app get helloHow to verify it worked: the app shows Synced and Healthy. Now test self-healing: kubectl scale deployment hello-app --replicas=5, wait a moment, and run argocd app get hello again — Argo CD reverts the replica count to match Git.
Where this bites vibecoders
The common mistake is wiring an AI-generated “GitOps” setup that still
kubectl applys from a CI job — the push model with none of the drift protection. The point of Argo CD is the pull model: the cluster converges on Git, and hand-edits get reverted. If your setup can’t answer “what happens when someone edits the cluster directly?”, it isn’t GitOps yet.
Where AI coding assistants get this wrong
- Using
latestimage tags, so “Synced” doesn’t mean “reproducible.” - Committing secrets into the Git repo Argo CD watches.
- Confusing the push and pull models and adding a CI step that defeats self-healing.
- Enabling auto-sync on a repo with no review process, turning every push into a production change.
Checklist
- Use the pull model: Argo CD watches Git, the cluster converges.
- Pin image tags and keep secrets out of the repo.
- Enable self-heal and confirm it reverts manual drift.
- Protect the Git branch so changes flow through review.
- Watch sync status and treat a “Degraded” app as an alert.
FAQ
What is the difference between Argo CD and Flux?
Both implement GitOps on Kubernetes. Argo CD is app-centric with a strong UI and per-app sync status; Flux is modular and more CLI/controller-oriented. Argo CD is the common first choice for its visibility. See What Is GitOps?.
What does “Synced” vs “Healthy” mean?
“Synced” means the cluster matches Git. “Healthy” means the resources are actually working — pods running, ready, not crash-looping. A deployment can be synced but unhealthy if the image is broken, which is why you check both.
Is auto-sync safe?
Auto-sync makes every merged Git change deploy automatically. It’s safe when the Git branch is protected and reviewed, and dangerous when anyone can push. Combine auto-sync with branch protection rather than choosing one over the other.