1 h 15 (S10.1 : 1 h 15)
M09 terminé (overlay dev en Kustomize)
chaque commit de flotte-app doit arriver en dev sans intervention
flotte-config1 h 15
CI = Construire + Tester + Publier l'image + Mettre à jour la configuration| Étape | Outil | Accès nécessaire |
|---|---|---|
| Construire, tester | GitLab CI, Jenkins | Code de flotte-app |
| Publier l'image | GitLab CI, Jenkins | Registre d'images |
Modifier le tag dans flotte-config |
GitLab CI, Jenkins | Écriture sur flotte-config |
| Déployer | ArgoCD | Cluster (depuis l'intérieur) |
la CI ne détient AUCUN accès au cluster (identifiants hors cluster supprimés)
flowchart LR Dev["Commit<br/>flotte-app"] --> CI["GitLab CI<br/>build + push"] CI --> Reg["Registre<br/>flotte-app:sha"] CI --> Cfg["Commit<br/>flotte-config"] Cfg --> Argo["ArgoCD<br/>webhook"] Argo --> K8s["flotte-dev<br/>canari"] Reg -. "pull" .-> K8s
$CI_COMMIT_SHORT_SHA : chaque déploiement remonte à un commit de codeflotte-config = journal des déploiementsflotte-app |
flotte-config |
|
|---|---|---|
| Contenu | Code, Dockerfile, .gitlab-ci.yml |
Manifestes, overlays, Applications |
| Déclencheur | Commit des développeurs | Commit de la CI ou d'un humain |
| Lu par | Runners CI | ArgoCD (jeton de déploiement, lecture) |
| Écrit par | Développeurs | CI (jeton dédié), équipe ops (merge request) |
recette / prod : merge request sur flotte-config (revue humaine)stages: [build, update-config]
build-image:
stage: build
image: docker:28
services: [docker:28-dind]
variables: {DOCKER_TLS_CERTDIR: "/certs"}
script:
- echo "$CI_REGISTRY_PASSWORD" |
docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
- docker build --build-arg GIT_SHA="$CI_COMMIT_SHA" -t "$IMAGE" .
- docker push "$IMAGE"IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA (variable globale du pipeline)CI_REGISTRY_*, CI_COMMIT_* : prédéfinies par GitLabflotte-config, rien d'autreupdate-config:
stage: update-config
image: alpine:3.22
rules: [{if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH}]
variables:
CONFIG_REPO_URL: $FLOTTE_CONFIG_URL
CONFIG_TOKEN: $FLOTTE_CONFIG_TOKEN
NEW_IMAGE: $IMAGE
before_script: [apk add --no-cache git kustomize]
script: [sh ci/update-config.sh]Sortie du script (testée) :
flotte-config updated: ghcr.io/stefanprodan/podinfo:6.15.0kustomize edit set image ghcr.io/stefanprodan/podinfo=$NEW_IMAGEflowchart LR G["GitLab<br/>push"] -- "POST /api/webhook<br/>X-Gitlab-Token" --> S["argocd-server"] S --> C["Rafraîchissement<br/>des applications"]
flotte-config → Settings → Webhooks → URL https://<ARGOCD>/api/webhook, événement Pushwebhook.gitlab.secret dans argocd-secret = jeton secret du webhookkind local : injoignable depuis GitLab.com → réconciliation ou Refresh en formationwebhook sans secret = n'importe qui peut déclencher des rafraîchissements
Jenkinsfile déclaratif (démonstration)stage('Update flotte-config') {
when { branch 'main' }
steps {
withCredentials([string(credentialsId: 'flotte-config-token', variable: 'TOKEN')]) {
sh '''CONFIG_REPO_URL="$FLOTTE_CONFIG_URL" CONFIG_TOKEN="$TOKEN" \
NEW_IMAGE="$IMAGE" sh ci/update-config.sh'''
}
}
}ci/update-config.sh : la logique GitOps ne dépend pas de l'outil de CIwithCredentials), jamais dans le Jenkinsfilewhen { branch 'main' } : job Multibranch Pipeline uniquement (étape sautée dans un job Pipeline simple)| Modèle | Principe | Limite |
|---|---|---|
| CI écrit dans Git (ce module) | Commit du nouveau tag | Une écriture par livraison |
| CI appelle ArgoCD | argocd app sync, app wait avec jeton ci-gitlab (M03) |
API ArgoCD joignable depuis la CI |
| Argo CD Image Updater | Surveille le registre, met à jour le tag | Composant supplémentaire |
| Promotion par merge request | Recette, prod : revue humaine | Délai de revue |
argocd app wait --health en fin de pipeline : la CI rapporte le résultat du déploiementflotte-config ; ArgoCD = déployerflotte-config ; ArgoCD applique.latest est interdit par Kubernetesadmin d'ArgoCDflotte-config et sur le registre d'imagesargocd-cm, clé webhook.gitlabargocd-secret, clé webhook.gitlab.secretwebhook.gitlab.secret du Secret argocd-secret.kustomize build --imagekustomize edit set image <NOM>=<NOUVEAU_NOM>:<TAG>kubectl set imageargocd app set --imagekustomize edit set image <NOM>=<NOUVEAU_NOM>:<TAG>.flotte-config ne relance-t-il pas la construction de l'image ?flotte-app n'est pas déclenché par flotte-config.