Argo CD 3 cheatsheet
Argo CD 3: Declarative setup
4 common Argo CD 3 tasks.
Define an Application in YAML
Keep applications in Git too. This one deploys a Helm chart folder with automated sync.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: web
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/example/deploy-repo.git
targetRevision: main
path: charts/web
helm:
valueFiles: [values-prod.yaml]
destination:
server: https://kubernetes.default.svc
namespace: web
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
Generate applications from a list
An ApplicationSet creates one Application per element, for example per environment.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: web-envs
namespace: argocd
spec:
generators:
- list:
elements:
- env: staging
- env: production
template:
metadata:
name: 'web-{{env}}'
spec:
project: default
source:
repoURL: https://github.com/example/deploy-repo.git
targetRevision: main
path: 'envs/{{env}}'
destination:
server: https://kubernetes.default.svc
namespace: 'web-{{env}}'
syncPolicy:
automated: {}
Create it from the file
Apply the Application manifest to the argocd namespace.
kubectl apply -n argocd -f application.yaml
Create a project
Projects limit which repositories, clusters and namespaces applications may use.
argocd proj create team-a \
--description "Team A" \
--src https://github.com/example/deploy-repo.git \
--dest https://kubernetes.default.svc,team-a