Prerequisites: argocd
An Application is the object you write to tell argocd “take what is at this path in this git repository and make it exist in this cluster and namespace, and keep it that way”. It is a custom resource the Argo CD install registers, and it is the single unit the application-controller reconciles. Almost everything you do with Argo CD is writing, reading, or watching Applications. This note pins down its fields and its sync behaviour, because every other GitOps note assumes you know what an Application is.
The three parts
A minimal Application has a source, a destination, and a sync policy. Read this one field by field.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: hello
namespace: argocd # Applications live in the argocd namespace
spec:
project: default # which AppProject's guardrails apply
source:
repoURL: https://github.com/PragalvaXFREZ/lab.git
targetRevision: main # branch, tag, or commit to track
path: kubernetes/apps/hello # the folder in the repo to render
destination:
server: https://kubernetes.default.svc # "this cluster"
namespace: hello # where the rendered objects go
syncPolicy:
automated:
selfHeal: true
prune: true
syncOptions:
- CreateNamespace=true- source answers “what should exist”.
repoURLis the repository,targetRevisionis the git ref to follow (trackmainand it picks up every push; pin a tag or commit and it freezes there), andpathis the folder inside the repo whose manifests this Application owns. The argocd repo-server is what renders that path into objects. - destination answers “where it goes”.
server: https://kubernetes.default.svcis the in-cluster API address and means “the same cluster Argo CD runs in”, which for devata is the only cluster.namespaceis where the rendered objects land, unless a manifest names its own namespace. - syncPolicy answers “how aggressively to keep it true”, covered below.
Sync state and health are two different questions
For every Application, Argo CD tracks two independent statuses, and confusing them is the most common early mistake.
- Sync status is
SyncedorOutOfSync: does the live cluster match what git renders to?OutOfSyncmeans a difference exists, whether or not anything is broken. - Health status is
Healthy,Progressing,Degraded, and so on: are the objects actually working? Argo CD derives this from the objects themselves, for example a Deployment whose pods are all ready isHealthy.
An app can be Synced and Degraded (git was applied faithfully but the image crashes) or OutOfSync and Healthy (the running version works fine, but git has moved ahead and not been applied yet). You read both, every time.
syncPolicy: manual, automated, self-heal, prune
By default an Application is observe-only. The controller tells you OutOfSync but waits for you to click Sync or run argocd app sync hello. That is manual sync, and it is a reasonable default for things you want a human to release deliberately.
syncPolicy.automated removes the human from the loop and turns the Application into a true reconciliation loop against git. Two flags decide how forceful it is:
- selfHeal. With auto-sync on, Argo CD applies git whenever the rendered manifests change.
selfHeal: trueextends that to the other direction: if the live cluster drifts away from git (someone runskubectl edit), Argo CD pushes it back to git’s version. Without self-heal, drift caused inside the cluster is reported but left alone; with it, git wins every time. - prune. When you delete a manifest from git, does Argo CD delete the corresponding live object? With
prune: false(the default), removing a file leaves the object orphaned in the cluster and the appOutOfSync, because deleting things is dangerous and Argo CD will not do it without permission. Withprune: true, git is fully authoritative: delete the file, and the object is removed. You want pruning on for real GitOps, but it is the flag to think twice about, because a badgit rmbecomes a cluster deletion.
syncOptions: [CreateNamespace=true] tells Argo CD to create the destination namespace if it does not exist, so you do not have to pre-create it by hand and break the “everything from git” rule.
Seeing it on a real Application
Once you have Argo CD installed and a hello Application created (the bootstrap walkthrough does this), these are the commands you live in:
argocd app list
argocd app get hello # source, destination, sync + health, and every managed resource
argocd app diff hello # exactly what differs between git and the cluster right now
argocd app sync hello # apply git now (only needed if auto-sync is off)An Application is therefore a contract: this path in git, applied to this place in the cluster, kept true to this degree. The next note builds one special Application whose job is to create all the others.