GitOps with Argo CD›02 · Installing Argo CD & the first app
Learning Hub / Delivery & Infrastructure as Code / GitOps with Argo CD

Lesson 02 of 7 · Modules

Installing Argo CD & the first app

Install Argo CD in a lab cluster, log in with the CLI and UI, and deploy your first Application from Git, first by manual sync and then with automated sync, pruning and self-heal. Watch it correct drift and roll back with git revert.

Beginner → Practitioner
Key wordsinstall Argo CDargocd CLIinitial admin passwordApplication CRsyncautomated syncpruneselfHealrollback

Install Argo CD (lab)

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

Older guides use a plain kubectl apply; recent versions recommend server-side apply because some CRDs are too large for client-side apply annotations. Follow the getting-started page for the version you install, and pin a version (not stable) for anything beyond a lab. Production installs usually use the Helm chart or the HA manifests (lesson 07).

Install the CLI (a single binary from the releases page), then log in:

$ kubectl port-forward svc/argocd-server -n argocd 8080:443 &
$ argocd admin initial-password -n argocd
$ argocd login localhost:8080 --username admin --insecure
$ argocd account update-password

After changing the password, delete the argocd-initial-admin-secret Secret. Open https://localhost:8080 for the UI.

Installing Argo CD is hiring the robot helper. An Application is the note you give it: "Keep the model on table 3 looking exactly like page 12 of this instruction book." You can tell it to only report differences (manual sync) or to fix them straight away (automated sync).

Your first Application

Create a Git repo (any host) with guestbook/deployment.yaml and guestbook/service.yaml, or use the public argoproj/argocd-example-apps repo. Then:

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     # the cluster Argo CD runs in
    namespace: guestbook
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
$ kubectl apply -f guestbook-app.yaml
$ argocd app get guestbook          # OutOfSync, Missing
$ argocd app sync guestbook
$ argocd app get guestbook          # Synced, Healthy

Automated sync, prune and self-heal

  syncPolicy:
    automated:
      prune: true       # delete resources removed from Git
      selfHeal: true    # revert manual changes in the cluster
    syncOptions:
      - CreateNamespace=true
Setting Reacts to a new commit Deletes removed resources Reverts kubectl edits
Manual ❌ (you click Sync) Only if you choose prune ❌
automated: {} ✅ ❌ ❌
+ prune: true ✅ ✅ ❌
+ selfHeal: true ✅ ✅ ✅

Rolling back

With automated sync, Git is the lever: git revert <bad-commit> and push. Argo CD syncs the previous state. argocd app rollback exists, but it's refused while automated sync is on, and any rollback that isn't in Git would be undone by the next sync anyway.

Try it: GitOps loop end to end (kind + a Git repo you own)

  1. Install Argo CD and log in with the CLI and UI.
  2. Fork or create a repo with a small Deployment and Service; create the Application with manual sync and sync it.
  3. Change the replica count in Git and push; see OutOfSync and argocd app diff; sync.
  4. Enable automated with prune and selfHeal. Now kubectl scale the Deployment by hand and watch Argo CD put it back.
  5. Delete the Service file from Git; confirm prune removes it. Then git revert and watch it return.

Going deeper: first production decisions

  • Pin Argo CD's version and manage Argo CD itself from Git (it can manage its own install, carefully).
  • Use private repos with read-only deploy keys or tokens (argocd repo add, or declarative repository Secrets).
  • Configure webhooks so syncs start on push instead of on the next poll.
  • Decide early whether teams may use manual sync in production (some want a human click for prod).

Recap

  • Install into argocd, log in, change the admin password, delete the initial secret.
  • An Application maps repo + path + revision → cluster + namespace.
  • automated syncs on new commits; prune deletes what's gone from Git; selfHeal reverts drift.
  • Roll back with git revert, not by editing the cluster.

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.