ArgoCD GitOps Tutorial

ArgoCD GitOps Tutorial

Introduction

Most Kubernetes deployments work like this: a pipeline builds an image, pushes it, and then something — a script, a kubectl apply, a person — updates the cluster. That last step is where deployments go wrong. Somebody applies the wrong file, somebody edits a Deployment by hand to “just fix it quickly”, and by Friday nobody can say what is actually running.

GitOps fixes this with one rule: Git is the source of truth. The desired state of the cluster lives in a Git repository, and a tool continuously makes the cluster match it. Argo CD is that tool — a declarative, GitOps continuous delivery tool for Kubernetes — and this tutorial installs it, deploys a first application from Git, and turns on the automation that makes manual deployment unnecessary. You need a cluster and the basics from our Kubernetes Tutorial for Beginners. If you have used Helm, the concepts will feel familiar — our Helm Tutorial covers charts, which Argo CD can deploy directly.

Version note (28 Nov 2026): the latest Argo CD is 3.6.3, released 24 November 2026 (3.6.0 went generally available on 3 November 2026). Supported minor versions are 3.6, 3.5 and 3.4; 3.3 reached end of life when 3.6 shipped.

What GitOps Means in Practice

GitOps is not a product; it is a way of operating. Four properties define it, and Argo CD implements all four:

  • Declarative. The desired state is written down — Kubernetes YAML, a Helm chart, or a Kustomize overlay — not executed as a series of imperative commands.
  • Versioned and immutable. The desired state lives in Git, so every change has an author, a timestamp and a review. Rollback means reverting a commit, not remembering what you typed.
  • Pulled automatically. Argo CD runs inside the cluster and pulls the desired state from Git. Nothing outside the cluster needs credentials to reach in — the cluster reaches out, which is a much smaller security surface.
  • Continuously reconciled. Argo CD constantly compares the live cluster state with Git and reports drift. If someone edits a Deployment by hand, Argo CD notices and can revert it.

The practical consequence is that “deploying” stops being an event. You merge a pull request, and the cluster converges to the new state — either automatically, or after a click in the Argo CD UI. The deployment history is the Git history, which means audits, rollbacks and “who changed this?” all have the same answer: look at the repository.

Installing Argo CD

Argo CD installs into your cluster with kubectl. Create its namespace first, then apply the official manifests. The current documentation adds two flags to the apply command — –server-side –force-conflicts — because the ApplicationSet custom resources are large enough to exceed the annotation size limit of a normal apply:

kubectl create namespace argocd
kubectl apply -n argocd \
  -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml \
  --server-side --force-conflicts

That installs the latest stable release. For production, pin a version instead of stable — replace stable in the URL with a release tag such as v3.6.3 — so an upgrade never happens by accident. Wait for the pods, then check they are all running:

kubectl get pods -n argocd
kubectl get svc -n argocd

The install creates several deployments: the API server, the repository server, the application controller that does the syncing, and supporting services. You do not need to understand each one to use Argo CD, but knowing the controller is the component that watches Git and the cluster will help when something does not sync.

Logging In for the First Time

Argo CD’s API server is not exposed outside the cluster by default. For learning, port-forward it to your laptop:

kubectl port-forward svc/argocd-server -n argocd 8080:443

Open https://localhost:8080 in a browser — accept the self-signed certificate warning for local use — and log in as admin. The initial password is auto-generated and stored in a Secret:

argocd admin initial-password -n argocd

That prints the password. Change it immediately after logging in, and delete the Secret (argocd-initial-admin-secret) once you have — leaving an initial password lying around in the cluster is a standing invitation. The same command-line tool, argocd, can do everything the UI does; install it if you prefer the terminal, but the UI is the better teacher for a first application.

Your First Application

An Application is Argo CD’s fundamental unit: a custom resource that binds a source — a Git repository, a path inside it, and a revision — to a destination — a cluster and a namespace — plus a sync policy. Create one in the UI (New App) or from a file. Here is a file version, guestbook.yaml, that deploys Argo CD’s own example application from its public demo repository:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: guestbook
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/argoproj/argocd-example-apps.git
    targetRevision: HEAD
    path: guestbook
  destination:
    server: https://kubernetes.default.svc
    namespace: guestbook
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Apply it and watch:

kubectl apply -f guestbook.yaml
argocd app list
argocd app get guestbook

Argo CD reads the manifests from the repository, creates the resources in the guestbook namespace, and reports the application as Synced. The UI shows the same thing visually: every resource, its health, and whether it matches Git. Change something in the repository — a replica count, an image tag — and Argo CD notices the drift within seconds. With the sync policy above, it fixes the drift itself.

Sync, Self-Heal and Prune — the Three Switches

The syncPolicy in that example has three settings, and understanding them is understanding Argo CD:

  • Automated sync. Without it, Argo CD detects drift but waits for you to click Sync (or run argocd app sync guestbook). With it, Argo CD applies changes from Git as soon as it sees them. Manual sync is the right default while you are learning; automated sync is the right default once you trust the pipeline that writes to Git.
  • Self-heal. With selfHeal: true, Argo CD reverts changes made directly in the cluster — the hand-edit that “just fixes it quickly” — back to the Git state. Without it, drift is reported but left alone. Self-heal is what makes Git the actual source of truth instead of a suggestion.
  • Prune. With prune: true, resources deleted from Git are deleted from the cluster. Without it, removing a manifest from the repository leaves the resource running — the classic orphaned-service problem. Turn prune on once you are confident in your Git workflow, and keep it off while you are experimenting.

Sync status is always one of two states: Synced (the cluster matches Git) or OutOfSync (it does not). Health is separate: a Synced application can still be unhealthy if its pods are crashing. Both are visible in the UI and in argocd app get, and both are worth checking after every change.

ApplicationSets — One Template, Many Environments

One Application per service is fine until you have ten services in four environments. ApplicationSet is the answer: a custom resource that generates many Application resources from a template, using generators. The common ones are the list generator (an explicit list of environments), the cluster generator (one Application per registered cluster), the Git directory generator (one per directory in a repository) and the matrix generator (combinations of the above).

A typical pattern is a Git directory generator: each environment is a directory in the repository (apps/prod/, apps/staging/), and the ApplicationSet creates one Application per directory. Adding an environment becomes creating a directory, not writing a new Application. Combined with a Helm chart per application — Argo CD deploys Helm charts and Kustomize overlays natively, as well as plain YAML — this is how teams run dozens of services across several clusters without drowning in configuration.

GitOps and CI — Where the Pipeline Ends

Argo CD is a delivery tool, not a build tool. The usual setup splits the work: a CI pipeline (GitHub Actions, Jenkins, GitLab CI — our GitHub Actions Tutorial covers one of them) builds and tests the code, pushes an image, and then updates the Git repository with the new image tag. Argo CD sees the commit and syncs the cluster. The pipeline never touches the cluster, and the cluster never trusts the pipeline — it trusts Git.

That split is the security argument for GitOps: the only credential that can change the cluster lives inside it, and every change passes through a pull request. It is also the audit argument: the Git history is a complete, reviewable record of everything that was ever deployed, and rolling back is a git revert followed by an automatic sync.

Common Beginner Mistakes

  • Pointing Argo CD at a branch that moves unexpectedly. targetRevision: HEAD is fine for learning. In production, pin a tag or a release branch so a stray commit cannot deploy itself.
  • Enabling automated sync before trusting the Git workflow. Automated sync deploys every merged commit. If your repository has no review process, that means every mistake deploys too. Manual sync first; automate when the process is ready.
  • Forgetting prune. Resources deleted from Git keep running without it. Turn prune on deliberately, once you understand what it deletes.
  • Leaving the initial admin password in place. Change it on first login and delete the argocd-initial-admin-secret Secret. The admin account has full access to every cluster Argo CD manages.
  • Exposing the UI without authentication in front of it. Port-forwarding is for learning. Production access goes through an ingress with proper authentication — never a bare LoadBalancer service on the API server.
  • Managing the same resource with both Argo CD and kubectl. Two owners of one object guarantees drift and confusion. Once Argo CD manages a resource, all changes go through Git.

FAQ

Is Argo CD the same as Flux?

No, but they solve the same problem. Both are GitOps continuous delivery tools for Kubernetes; Argo CD has a web UI and an Application CRD, Flux is more CLI-driven and lighter. Teams usually pick one. Learning Argo CD’s concepts — sync, drift, self-heal — transfers directly to Flux.

Do I still need Helm if I use Argo CD?

Yes, often. Argo CD deploys Helm charts, Kustomize overlays and plain YAML. Helm packages the application; Argo CD decides when it gets deployed. They complement each other.

What happens if Argo CD itself goes down?

Nothing changes in the cluster — your applications keep running. Argo CD only manages desired state; it is not in the request path. When it comes back, it compares Git with the cluster and syncs any drift that accumulated while it was away.

Can Argo CD manage multiple clusters?

Yes. Register additional clusters with argocd cluster add, and an Application’s destination can point at any of them. ApplicationSets with the cluster generator are the standard way to deploy the same application everywhere.

Is GitOps only for Kubernetes?

The pattern works anywhere a desired state can be declared, but Argo CD is Kubernetes-specific. The same idea — Git as the source of truth, automated reconciliation — is applied to other systems with different tools.

Conclusion

Argo CD changes deployment from an action into a property of the system: merge to Git, and the cluster follows. The pieces you set up here — the install, the first Application, automated sync with self-heal and prune — are the whole model, and everything else (ApplicationSets, multi-cluster, Helm chart sources) is scale on top of it.

The habit to take away is the GitOps one: if a change is worth making, it is worth committing. The cluster will take care of the rest — and the next time somebody asks what is running in production, the answer is a Git log, not a memory.

Sources checked 28 Nov 2026: Argo CD documentation (Getting Started — install with –server-side –force-conflicts, admin password from argocd-initial-admin-secret, port-forward svc/argocd-server 8080:443); Argo CD releases via endoflife.date (3.6.3, 24 Nov 2026; 3.6.0 GA 3 Nov 2026; 3.3 EOL with 3.6); Argo CD concepts (Application CRD, sync policy, self-heal, ApplicationSet). External references: Argo CD documentation · Argo CD Getting Started.

—

Scroll to Top