TExcelTAD
Home › GitOps: Argo CD & Flux › Applications

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

yaml
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":

bash · try it yourself
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.yaml
Summary: 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:

  1. UI "New App" form: fine for exploring, invisible to review.

  2. CLI, which writes the same object:

    bash
    argocd 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=true

    Handy for experiments; the object it creates exists only in the cluster, not in Git.

  3. 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)

bash
argocd app list
argocd app get linkly-staging

Sample output:

text
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 created

Two 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?

  1. Only the Application object is deleted
  2. Argo CD deletes the app's Kubernetes objects first, then the Application
  3. The deletion is blocked forever
  4. Argo CD recreates the Application from Git

An app shows Synced and Degraded. What does that tell you?

  1. Someone changed the cluster by hand
  2. The cluster matches Git, but what Git describes isn't working
  3. Argo CD can't reach Git
  4. The sync is still running

Why validate Applications with kubeconform -strict?

  1. Argo CD can't read unvalidated YAML
  2. It rejects unknown fields, so a misspelled syncPolicy key fails in CI instead of being silently ignored
  3. It applies them to the cluster
  4. It renders the Helm chart