Aller au contenu principal

Exercices et projets pratiques


Table des matières

  1. Exercice 1 : Installation complète
  2. Exercice 2 : Déploiement GitOps
  3. Exercice 3 : Multi-environnement
  4. Exercice 4 : ApplicationSet
  5. Projet final : Pipeline complet
  6. Ressources complémentaires

1 - Exercice 1 : Installation complète

Objectif

Installer Argo CD et le configurer pour l'accès.

Étapes

# 1. Créer un cluster (si pas existant)
minikube start --memory=4096
# ou
kind create cluster --name argocd-demo

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

# 3. Attendre les pods
kubectl wait --for=condition=Ready pods --all -n argocd --timeout=300s

# 4. Récupérer le mot de passe
kubectl -n argocd get secret argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -d && echo

# 5. Port-forward
kubectl port-forward svc/argocd-server -n argocd 8080:443 &

# 6. Se connecter
argocd login localhost:8080 --username admin --password <password> --insecure

# 7. Changer le mot de passe
argocd account update-password

Validation

🔝 Retour à la table des matières


2 - Exercice 2 : Déploiement GitOps

Objectif

Déployer une application en mode GitOps.

Créer le repository GitOps

# Créer un repo sur GitHub
# Structure :
gitops-demo/
└── apps/
└── nginx/
├── deployment.yaml
└── service.yaml
# apps/nginx/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80
# apps/nginx/service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
selector:
app: nginx
ports:
- port: 80
targetPort: 80

Créer l'application Argo CD

# nginx-app.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: nginx
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/YOUR-USER/gitops-demo.git
path: apps/nginx
targetRevision: HEAD
destination:
server: https://kubernetes.default.svc
namespace: demo
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
kubectl apply -f nginx-app.yaml

Tester le GitOps

# Modifier replicas dans Git (2 → 3)
# Pousser le changement

# Observer dans Argo CD
argocd app get nginx

# L'application se synchronise automatiquement

🔝 Retour à la table des matières


3 - Exercice 3 : Multi-environnement

Objectif

Déployer sur dev et prod avec Kustomize.

Structure

gitops-demo/
└── apps/
└── myapp/
├── base/
│ ├── kustomization.yaml
│ ├── deployment.yaml
│ └── service.yaml
└── overlays/
├── dev/
│ └── kustomization.yaml
└── prod/
├── kustomization.yaml
└── replicas-patch.yaml

Base

# base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml

Overlay Dev

# overlays/dev/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: dev
resources:
- ../../base

Overlay Prod

# overlays/prod/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: prod
resources:
- ../../base
patches:
- path: replicas-patch.yaml
# overlays/prod/replicas-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 5

Applications Argo CD

# myapp-dev.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp-dev
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/YOUR-USER/gitops-demo.git
path: apps/myapp/overlays/dev
destination:
server: https://kubernetes.default.svc
namespace: dev
syncPolicy:
automated:
prune: true
syncOptions:
- CreateNamespace=true
---
# myapp-prod.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp-prod
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/YOUR-USER/gitops-demo.git
path: apps/myapp/overlays/prod
destination:
server: https://kubernetes.default.svc
namespace: prod
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true

🔝 Retour à la table des matières


4 - Exercice 4 : ApplicationSet

Objectif

Automatiser avec ApplicationSet.

ApplicationSet multi-environnement

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp-envs
namespace: argocd
spec:
generators:
- list:
elements:
- env: dev
autosync: "true"
- env: staging
autosync: "true"
- env: prod
autosync: "false"
template:
metadata:
name: 'myapp-{{env}}'
spec:
project: default
source:
repoURL: https://github.com/YOUR-USER/gitops-demo.git
path: 'apps/myapp/overlays/{{env}}'
destination:
server: https://kubernetes.default.svc
namespace: '{{env}}'
syncPolicy:
syncOptions:
- CreateNamespace=true

Vérification

argocd app list
# NAME CLUSTER NAMESPACE STATUS
# myapp-dev https://kubernetes.default.svc dev Synced
# myapp-staging https://kubernetes.default.svc staging Synced
# myapp-prod https://kubernetes.default.svc prod OutOfSync

🔝 Retour à la table des matières


5 - Projet final : Pipeline complet

Objectif

Créer un pipeline GitOps complet avec :

  • Application multi-environnement
  • Secrets management
  • RBAC
  • Notifications

Architecture

Structure du projet

gitops-final/
├── apps/
│ └── webapp/
│ ├── base/
│ │ ├── kustomization.yaml
│ │ ├── deployment.yaml
│ │ ├── service.yaml
│ │ └── sealed-secret.yaml
│ └── overlays/
│ ├── dev/
│ ├── staging/
│ └── prod/
├── infrastructure/
│ ├── argocd/
│ │ ├── projects.yaml
│ │ └── rbac.yaml
│ └── applicationsets/
│ └── webapp.yaml
└── README.md

Livrables attendus

  • Repository GitOps structuré
  • AppProject avec restrictions
  • RBAC configuré
  • ApplicationSet pour 3 environnements
  • Sealed Secret pour les credentials
  • Documentation

🔝 Retour à la table des matières


6 - Ressources complémentaires

Documentation officielle

RessourceURL
Argo CD Docshttps://argo-cd.readthedocs.io
GitHubhttps://github.com/argoproj/argo-cd
Argo Projecthttps://argoproj.github.io

Outils complémentaires

OutilDescription
Argo RolloutsDéploiements progressifs (canary, blue-green)
Argo EventsEvent-driven workflows
Argo WorkflowsOrchestration de workflows K8s

Certifications

  • Certified Kubernetes Administrator (CKA)
  • Certified GitOps Associate (CGOA)

Livres recommandés

  • "GitOps and Kubernetes" - Billy Yuen et al.
  • "Kubernetes Patterns" - Bilgin Ibryam

🔝 Retour à la table des matières


Félicitations !

Vous avez terminé le cours Argo CD ! Vous maîtrisez maintenant :

  • Installation et configuration d'Argo CD
  • Création d'Applications (UI, CLI, YAML)
  • Stratégies de synchronisation
  • ApplicationSets pour l'automatisation
  • Gestion multi-cluster
  • Sécurité et RBAC

Prochaines étapes

  1. Pratiquer sur des projets personnels
  2. Explorer Argo Rollouts pour les déploiements avancés
  3. Contribuer à la communauté Argo
  4. Certifier vos compétences (CGOA, CKA)

← Retour à la table des matières du cours