GitOps-Konzept
Traditionell:
Developer → kubectl apply → Cluster
GitOps mit ArgoCD:
Developer → Git Push → ArgoCD erkennt Diff → Apply
Vorteile:
- Vollstaendige Audit-History (git log)
- Rollback = git revert
- Mehrere Umgebungen aus einem Repo
- Keine kubectl-Zugaenge fuer Entwickler noetig
- Cluster-Drift-Erkennung
ArgoCD installieren
# Namespace erstellen
kubectl create namespace argocd
# ArgoCD installieren
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Warten bis alle Pods ready sind
kubectl wait --for=condition=Ready pods --all -n argocd --timeout=300s
# Initialer Admin-Passwort
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d && echo
# Port-Forward fuer Zugriff
kubectl port-forward svc/argocd-server -n argocd 8080:443
# https://localhost:8080 / admin / (passwort oben)
# argocd CLI installieren
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x argocd && mv argocd /usr/local/bin/
# Login
argocd login localhost:8080 --username admin --password PASSWORT --insecure
Erste Application
# Application aus Git-Repo
argocd app create meine-app --repo https://github.com/meinefirma/k8s-manifeste.git --path apps/meine-app/overlays/production --dest-server https://kubernetes.default.svc --dest-namespace production --sync-policy automated --auto-prune --self-heal
# Application-Status
argocd app get meine-app
argocd app sync meine-app
# App-Status in Web-UI:
# Synced = Git und Cluster identisch
# OutOfSync = Unterschied gefunden
# Degraded = Pods nicht healthy
ApplicationSet (Multi-Cluster/Multi-Env)
# applicationset.yaml
# Erstellt automatisch Apps fuer dev, staging, prod
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: meine-app-envs
namespace: argocd
spec:
generators:
- list:
elements:
- env: dev
cluster: https://kubernetes.default.svc
namespace: meine-app-dev
- env: staging
cluster: https://staging-cluster:6443
namespace: meine-app-staging
- env: prod
cluster: https://prod-cluster:6443
namespace: meine-app-prod
template:
metadata:
name: 'meine-app-{{env}}'
spec:
project: default
source:
repoURL: https://github.com/meinefirma/k8s-manifeste.git
targetRevision: HEAD
path: 'apps/meine-app/overlays/{{env}}'
destination:
server: '{{cluster}}'
namespace: '{{namespace}}'
syncPolicy:
automated:
prune: true
selfHeal: true
FAQ
Was ist der Unterschied zwischen ArgoCD und Flux?
Beide implementieren GitOps. ArgoCD hat bessere Web-UI und Multi-Cluster-Support. Flux ist leichtgewichtiger und Kubernetes-nativer (Custom Resources). Fuer Teams mit Web-UI-Praeferenz: ArgoCD.
Fazit
ArgoCD ist der Standard fuer Kubernetes GitOps: visuelle Sync-Status-Uebersicht, automatische Drift-Korrektur und vollstaendige Git-History als Audit-Log.
Kubernetes GitOps fuer KMU in Heidelberg, Mannheim und der Rhein-Neckar-Region. Beratung anfragen.