Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 4Naam in de cursus: Applications, sync and ApplicationSets

Deploy apps with Argo CD

An Argo CD Application links a Git path to a cluster and namespace. Sync policies decide if Argo CD applies changes automatically, removes deleted objects, and repairs drift. App of apps and ApplicationSets manage many applications.

  • 5 Lessen
  • 3 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

4.1

Create an Application

The Application itself is YAML — keep it in Git too.

shop-prod.yaml
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=true
kubectl apply -f shop-prod.yaml
argocd app get shop-prod
Sync Status:   Synced to main (3f2a9c1)
Health Status: Healthy

4.2

Understand sync and health

Sync status = does the cluster match Git? Health = are the objects working?

SettingEffect
Manual syncArgo CD shows OutOfSync; a person clicks Sync
automatedApplies new commits automatically
prune: trueDeletes objects that were removed from Git
selfHeal: trueReverts 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           2d

Onthoud

With selfHeal, a manual kubectl scale is undone within minutes — change the replicas in Git instead.

4.3

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.

waves (metadata part)
metadata:
  annotations:
    argocd.argoproj.io/sync-wave: "-1"
---
metadata:
  annotations:
    argocd.argoproj.io/hook: PreSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded

4.4

Manage 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.

appset.yaml
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 } }

4.5

Limit teams with projects

An AppProject limits which repositories, clusters, namespaces and object kinds a team's applications may use.

project.yaml
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 }

Alle commando's in dit hoofdstuk