How to Create an Argo CD Application
An Argo CD Application is a custom resource that maps a Git source (repo, path, revision) to a destination cluster and namespace.
Write an Application manifest with spec.source (repo, path, targetRevision) and spec.destination. Add an automated syncPolicy so Argo CD reconciles whenever Git changes.
Steps
- Create an
Applicationin theargocdnamespace. - Set
sourceto your repo, path, andtargetRevision. - Set
destinationto the target cluster server and namespace. - Add
syncPolicy.automatedwithpruneandselfHeal.
Application manifest
apps/api/application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: api
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/my-org/deploy-config
path: apps/api
targetRevision: main
destination:
server: https://kubernetes.default.svc
namespace: api
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=trueGotchas
prune: truedeletes resources removed from Git; without it, deleted manifests linger in the cluster.selfHeal: truereverts manualkubectledits, which is what makes GitOps authoritative.