ArgoCD est un outil de déploiement continu GitOps pour Kubernetes. Il synchronise l’état du cluster avec un dépôt Git : Git devient la source de vérité unique pour tout ce qui est déployé.


Principe GitOps

Développeur
   │  git push
   ▼
Dépôt Git (manifests YAML / Helm charts)
   │
   ▼  ArgoCD surveille en continu (pull)
ArgoCD
   │  kubectl apply (si diff détecté)
   ▼
Cluster Kubernetes  ←→  État attendu == État réel ✅

Contrairement au CI/CD classique (push), ArgoCD pull l’état depuis Git et corrige les dérives automatiquement.


Installation via Helm

helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
 
helm install argocd argo/argo-cd \
  --namespace argocd \
  --create-namespace

Accès à l’interface web :

kubectl port-forward svc/argocd-server -n argocd 8080:443
 
# Récupérer le mot de passe admin initial
kubectl get secret argocd-initial-admin-secret -n argocd \
  -o jsonpath="{.data.password}" | base64 -d

Concept clé : l’Application

Une Application ArgoCD définit :

  • La source (repo Git + path + branche)
  • La destination (cluster + namespace)
  • La politique de sync

Exemple : Application simple (manifests YAML)

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: mon-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/mon-org/mon-repo.git
    targetRevision: main
    path: k8s/prod                    # dossier contenant les manifests
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true                     # supprime les ressources absentes de Git
      selfHeal: true                  # corrige les dérives manuelles
    syncOptions:
    - CreateNamespace=true

Exemple : Application Helm

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: ingress-nginx
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://kubernetes.github.io/ingress-nginx
    chart: ingress-nginx
    targetRevision: 4.10.0
    helm:
      values: |
        controller:
          replicaCount: 2
          service:
            type: LoadBalancer
  destination:
    server: https://kubernetes.default.svc
    namespace: ingress-nginx
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
    - CreateNamespace=true

États possibles d’une Application

ÉtatSignification
SyncedCluster == Git ✅
OutOfSyncDiff détecté entre Git et le cluster
HealthyTous les pods/ressources sont sains
DegradedRessources en erreur (CrashLoopBackOff, etc.)
ProgressingDéploiement en cours
UnknownArgoCD ne peut pas déterminer l’état

Gestion multi-environnements

Pattern recommandé avec App of Apps :

repo-gitops/
├── apps/
│   ├── dev/
│   │   ├── mon-app.yaml      # Application ArgoCD → env dev
│   │   └── ingress.yaml
│   └── prod/
│       ├── mon-app.yaml      # Application ArgoCD → env prod
│       └── ingress.yaml
└── root-app.yaml             # "App of Apps" qui gère tout

Commandes CLI utiles

# Lister les applications
argocd app list
 
# Synchroniser manuellement
argocd app sync mon-app
 
# Voir les diffs avant sync
argocd app diff mon-app
 
# Historique des déploiements
argocd app history mon-app
 
# Rollback vers une version précédente
argocd app rollback mon-app 3

Liens