ArgoCD

GitOps Continuous Delivery fur Kubernetes - Apps aus Git synchronisieren, automatische Heilung, deklarative Deployments

TL;DR

Was: Deklaratives GitOps Continuous-Delivery-Tool für Kubernetes.

Warum: Git als einzige Wahrheitsquelle, automatische Synchronisierung, visuelles Dashboard, Multi-Cluster-Unterstützung.

Quick Start

In Kubernetes installieren:

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

# Auf Pods warten
kubectl wait --for=condition=Ready pods --all -n argocd --timeout=300s

CLI installieren:

# macOS
brew install argocd

# Linux
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x argocd && sudo mv argocd /usr/local/bin/

UI aufrufen:

# Port-Weiterleitung
kubectl port-forward svc/argocd-server -n argocd 8080:443

# Initiales Passwort abrufen
argocd admin initial-password -n argocd

# Anmelden (Benutzer: admin)
argocd login localhost:8080

Cheatsheet

BefehlBeschreibung
argocd app listAnwendungen auflisten
argocd app createAnwendung erstellen
argocd app sync nameAnwendung synchronisieren
argocd app get nameApp-Details abrufen
argocd app delete nameAnwendung löschen
argocd cluster add ctxCluster hinzufügen
argocd repo add urlGit-Repo hinzufügen

Gotchas

Application manifest

# application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/user/repo.git
    targetRevision: HEAD
    path: k8s
  destination:
    server: https://kubernetes.default.svc
    namespace: my-app
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Create app via CLI

argocd app create my-app \
  --repo https://github.com/user/repo.git \
  --path k8s \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace my-app \
  --sync-policy automated

Helm application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: nginx
  namespace: argocd
spec:
  source:
    repoURL: https://charts.bitnami.com/bitnami
    chart: nginx
    targetRevision: 15.0.0
    helm:
      values: |
        replicaCount: 2
        service:
          type: LoadBalancer
  destination:
    server: https://kubernetes.default.svc
    namespace: nginx

Kustomize application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  source:
    repoURL: https://github.com/user/repo.git
    path: overlays/production
    targetRevision: main
    kustomize:
      images:
        - myapp=myrepo/myapp:v2
  destination:
    server: https://kubernetes.default.svc
    namespace: production

Sync operations

# Manuelle Synchronisierung
argocd app sync my-app

# Sync mit Prune
argocd app sync my-app --prune

# Force-Sync (ersetzen)
argocd app sync my-app --force

# Rollback
argocd app rollback my-app

Next Steps