Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Create an Application
The Application itself is YAML — keep it in Git too.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: shop-prod
namespace: argocd
spec:
project: default
source:
repoURL: git@github.com:s0sta/shop-deploy.git
targetRevision: main
path: overlays/prod
destination:
server: https://kubernetes.default.svc
namespace: shop-prod
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=trueUnderstand sync and health
Sync status = does the cluster match Git? Health = are the objects working?
| Setting | Effect |
|---|---|
| Manual sync | Argo CD shows OutOfSync; a person clicks Sync |
automated | Applies new commits automatically |
prune: true | Deletes objects that were removed from Git |
selfHeal: true | Reverts manual changes in the cluster |
kubectl scale deploy web -n shop-prod --replicas=1
argocd app get shop-prod | grep Sync
Sync Status: Synced to main (3f2a9c1)
kubectl get deploy web -n shop-prod
NAME READY UP-TO-DATE AVAILABLE AGE
web 4/4 4 4 2dOnthoud
With selfHeal, a manual kubectl scale is undone within minutes — change the replicas in Git instead.
Control the order with sync waves
Annotations order the apply: namespaces and CRDs first, then the database, then the app; hooks run jobs before or after a sync.
metadata:
annotations:
argocd.argoproj.io/sync-wave: "-1"
---
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: HookSucceededManage many apps
App of apps: one Application points to a folder full of Application files. ApplicationSet: one template makes an Application per environment, cluster or folder.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata: { name: shop, namespace: argocd }
spec:
generators:
- list:
elements:
- { env: staging }
- { env: prod }
template:
metadata: { name: "shop-{{env}}" }
spec:
project: default
source:
repoURL: git@github.com:s0sta/shop-deploy.git
targetRevision: main
path: "overlays/{{env}}"
destination:
server: https://kubernetes.default.svc
namespace: "shop-{{env}}"
syncPolicy: { automated: { prune: true, selfHeal: true } }Limit teams with projects
An AppProject limits which repositories, clusters, namespaces and object kinds a team's applications may use.
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata: { name: shop-team, namespace: argocd }
spec:
sourceRepos: ["git@github.com:s0sta/shop-deploy.git"]
destinations:
- { server: https://kubernetes.default.svc, namespace: "shop-*" }
clusterResourceWhitelist: []
namespaceResourceBlacklist:
- { group: "", kind: ResourceQuota }