Applications
An Argo CD Application is one unit of deployment: this source, rendered this way, applied to this cluster and namespace, under this policy. Everything else in Argo CD (Projects, ApplicationSets, app-of-apps) exists to create, constrain or group Applications.
Anatomy
apiVersion: argoproj.io/v1alpha1 # still v1alpha1 in Argo CD 3.x, despite being stable
kind: Application
metadata:
name: linkly-staging
namespace: argocd # Applications live in Argo CD's namespace (by default)
finalizers:
- resources-finalizer.argocd.argoproj.io # deleting the Application deletes its objects too
spec:
project: linkly # the AppProject that limits what this app may do
source: # WHAT
repoURL: https://github.com/acme/linkly-deploy.git
targetRevision: main # branch, tag or commit SHA (for Helm repos: chart version)
path: charts/linkly
helm:
releaseName: linkly
valueFiles: [../../apps/linkly/staging/values.yaml]
destination: # WHERE
server: https://kubernetes.default.svc # or `name: staging-cluster`
namespace: linkly-staging
syncPolicy: # HOW (next lessons)
syncOptions: [CreateNamespace=true]| Field | Notes |
|---|---|
spec.source.targetRevision |
main follows the branch; a tag or SHA pins it. HEAD means the default branch |
spec.source.path |
a folder in the repo; Argo CD detects the tool: Chart.yaml → Helm, kustomization.yaml → Kustomize, otherwise plain YAML (directory.recurse: true for subfolders) |
spec.sources (plural) |
several sources merged into one app, e.g. a chart from an OCI registry plus values from Git (Helm & Kustomize Sources) |
spec.destination |
server (API URL) or name (registered cluster name), not both |
| the finalizer | without it, deleting the Application leaves its objects running (sometimes what you want) |
Write and validate them before Argo CD sees them
The Application is just YAML in Git, so validate it like anything else. The image's kubeconform has Argo CD's CRD schemas; -strict also catches misspelled fields, a common reason for "my auto-sync isn't working":
mkdir -p clusters/staging && cd clusters/staging
cat > linkly.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: linkly-staging
namespace: argocd
finalizers: [resources-finalizer.argocd.argoproj.io]
spec:
project: linkly
source:
repoURL: https://github.com/acme/linkly-deploy.git
targetRevision: main
path: charts/linkly
helm:
releaseName: linkly
valueFiles: [../../apps/linkly/staging/values.yaml]
destination: {server: https://kubernetes.default.svc, namespace: linkly-staging}
syncPolicy:
automated: {prune: true, selfHeal: true}
syncOptions: [CreateNamespace=true]
EOF
kubeconform -strict -summary linkly.yaml
sed 's/automated:/automatic:/' linkly.yaml > typo.yaml
kubeconform -strict typo.yamlSummary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0
typo.yaml - Application linkly-staging is invalid: problem validating schema. Check JSON formatting: jsonschema validation failed with 'file:///opt/crd-schemas/argoproj.io/application_v1alpha1.json#' - at '/spec/syncPolicy': additional properties 'automatic' not allowed
Without -strict, the misspelled automatic would pass validation. Depending on how the Application is applied, the API server then either rejects it or prunes the unknown field, and Argo CD runs the app with manual sync while everyone believes auto-sync is on.
Creating an Application
Three ways, from least to most GitOps:
UI "New App" form: fine for exploring, invisible to review.
CLI, which writes the same object:
bashargocd app create linkly-staging \ --project linkly \ --repo https://github.com/acme/linkly-deploy.git --revision main --path charts/linkly \ --values ../../apps/linkly/staging/values.yaml --release-name linkly \ --dest-server https://kubernetes.default.svc --dest-namespace linkly-staging \ --sync-policy automated --auto-prune --self-heal --sync-option CreateNamespace=trueHandy for experiments; the object it creates exists only in the cluster, not in Git.
Declaratively: commit the YAML above and let something apply it (
kubectl apply -n argocd -f, or better an app of apps). This is the recommended way: Applications are reviewed like any other change.
Looking at an Application (sample session)
argocd app list
argocd app get linkly-stagingSample output:
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET
argocd/linkly-staging https://kubernetes.default.svc linkly-staging linkly Synced Healthy Auto-Prune <none> https://github.com/acme/linkly-deploy.git charts/linkly main
Name: argocd/linkly-staging
Project: linkly
Server: https://kubernetes.default.svc
Namespace: linkly-staging
URL: https://argocd.example.com/applications/linkly-staging
Source:
- Repo: https://github.com/acme/linkly-deploy.git
Target: main
Path: charts/linkly
Helm Values: ../../apps/linkly/staging/values.yaml
SyncWindow: Sync Allowed
Sync Policy: Automated (Prune)
Sync Status: Synced to main (40b2f3e)
Health Status: Healthy
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
ConfigMap linkly-staging linkly-config Synced configmap/linkly-config created
Service linkly-staging linkly Synced Healthy service/linkly created
apps Deployment linkly-staging linkly Synced Healthy deployment.apps/linkly created
gateway.networking.k8s.io HTTPRoute linkly-staging linkly Synced httproute.gateway.networking.k8s.io/linkly createdTwo independent statuses, always read together:
| Sync status | Health status |
|---|---|
does the live state match Git? Synced, OutOfSync, Unknown |
is the app working? Healthy, Progressing, Degraded, Suspended, Missing, Unknown |
Synced + Degraded means "we applied exactly what Git says, and it's broken" (a bad release). OutOfSync + Healthy means "it works, but it isn't what Git says" (drift, or a pending change).
Test yourself
What happens when you delete an Application that has the resources-finalizer.argocd.argoproj.io finalizer?
- Only the Application object is deleted
- Argo CD deletes the app's Kubernetes objects first, then the Application
- The deletion is blocked forever
- Argo CD recreates the Application from Git
An app shows Synced and Degraded. What does that tell you?
- Someone changed the cluster by hand
- The cluster matches Git, but what Git describes isn't working
- Argo CD can't reach Git
- The sync is still running
Why validate Applications with kubeconform -strict?
- Argo CD can't read unvalidated YAML
- It rejects unknown fields, so a misspelled
syncPolicykey fails in CI instead of being silently ignored - It applies them to the cluster
- It renders the Helm chart