Runbook Day-0 — du serveur nu au cluster GitOps
Le strict minimum manuel, fait une seule fois, pour amener un serveur nu à un cluster GitOps opérationnel. Ensuite, tout passe par Git. Ce runbook se rejoue tel quel pour monter un nouveau serveur (qualification, prod).
Trois natures d'action
| Nature | Exemples |
|---|---|
| Manuel — une fois (ce runbook) | durcissement hôte · k3s · Argo CD · credentials · operators à CRD géantes · secrets de bootstrap |
| Branchement externe | DNS → IP · pull GHCR · GitHub ↔ Argo · annuaire AD |
| Automatique — GitOps | plateforme légère · services · fronts (via app-of-apps) |
Prérequis
- VPS Ubuntu 22.04+ / Debian, accès SSH (root ou sudo).
- Un domaine dont on contrôle le DNS (ex. fga.antah.dev).
- Un PAT GitHub : lecture des packages GHCR + lecture du dépôt fga-infrastructure.
A · Durcir l'hôte
- Utilisateur sudo dédié + clés SSH ; désactiver PermitRootLogin et PasswordAuthentication.
- Pare-feu (ufw) : autoriser 22, 80, 443 ; restreindre le port API 6443 à l'IP admin.
- apt update && apt upgrade, fail2ban, swap off, hostname + timezone.
B · Installer k3s
curl -sfL https://get.k3s.io | sh -s - --tls-san <ADR> --write-kubeconfig-mode 644
k3s embarque containerd + Traefik (ingress) + local-path (storage) + CoreDNS + metrics-server. Le --tls-san ajoute l'adresse au certificat de l'API (sinon TLS injoignable depuis l'extérieur).
C · Brancher le DNS (externe)
Enregistrements A vers l'IP du VPS : *.fga.antah.dev (ou explicitement argocd., auth., portail., admin., grafana., s3., minio., doc-tech.). Requis pour l'ingress et le TLS Let's Encrypt (HTTP-01).
D · Installer Argo CD
kubectl create namespace argocd
# --server-side : le CRD ApplicationSet dépasse la limite d'annotation du client-side apply
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml --server-side --force-conflicts
# mot de passe admin initial :
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d; echo
E · Câbler les accès (secrets de bootstrap)
Les seuls secrets posés à la main (avant que sealed-secrets ne tourne). Un même PAT (scopes repo + read:packages) suffit.
# 1) Argo → dépôt privé (lecture de fga-infrastructure sur qa) kubectl -n argocd create secret generic fga-infra-repo \ --from-literal=type=git \ --from-literal=url=https://github.com/Antah-SARL/fga-infrastructure.git \ --from-literal=username=<user> --from-literal=password=<PAT> kubectl -n argocd label secret fga-infra-repo argocd.argoproj.io/secret-type=repository # 2) Pull GHCR (images privées) kubectl create namespace sigfga-staging kubectl -n sigfga-staging create secret docker-registry ghcr \ --docker-server=ghcr.io --docker-username=<user> --docker-password=<PAT>
F · Lancer le GitOps (app-of-apps)
Appliquer l'Application racine gitops/bootstrap/root-staging.yaml (une fois). Argo prend alors le relais : AppProject → Namespaces → plateforme → cluster PostgreSQL → ApplicationSets, dans l'ordre des sync-waves.
kubectl apply -f gitops/bootstrap/root-staging.yaml # (ou, si le dépôt n'est pas cloné sur le serveur, appliquer le même manifeste en ligne — cf. README)
F-bis · Exposer Argo CD
kubectl -n argocd patch configmap argocd-cmd-params-cm --type merge -p '{"data":{"server.insecure":"true"}}'
kubectl -n argocd rollout restart deploy argocd-server
Traefik met le TLS Let's Encrypt devant (Argo écoute en HTTP interne). L'ingress argocd.fga.antah.dev est déclaratif (GitOps). Accès : https://argocd.fga.antah.dev.
F-ter · Bootstrap des operators à CRD géantes
Ces operators publient des CRD trop grosses pour Argo → on les installe en direct, server-side, une fois. Leurs CR restent en GitOps (cf. Socle GitOps).
| Operator | Commande |
|---|---|
| CloudNativePG | kubectl apply --server-side -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.30/releases/cnpg-1.30.0.yaml |
| Keycloak | kubectl create namespace keycloak ; kubectl apply --server-side -k 'github.com/keycloak/keycloak-k8s-resources/kubernetes?ref=26.7.0' |
| Strimzi | kubectl apply --server-side -f 'https://strimzi.io/install/latest?namespace=sigfga-staging' -n sigfga-staging |
| Prometheus (CRD) | kubectl apply --server-side -f https://github.com/prometheus-operator/prometheus-operator/releases/download/v0.92.1/stripped-down-crds.yaml |
kubectl -n argocd rollout restart statefulset argocd-application-controller
F-quater · Secrets de bootstrap (staging)
Secrets non versionnés (comme ceux de la section E), référencés par les charts via existingSecret. Mots de passe forts, jamais en clair dans Git.
kubectl -n sigfga-staging create secret generic minio-root \ --from-literal=rootUser=sigfgaadmin --from-literal=rootPassword='<fort>' kubectl create namespace monitoring kubectl -n monitoring create secret generic grafana-admin \ --from-literal=admin-user=admin --from-literal=admin-password='<fort>'
G · Finir les branchements applicatifs
- CI : dans chaque dépôt applicatif, le secret GITOPS_TOKEN (write-back). Sur un plan GitHub gratuit avec repos privés, c'est un secret par dépôt.
- Realms / AD : la fédération du realm agents attend la livraison de l'annuaire — non bloquant pour le portail.
Après le Day-0
Plus rien à la main sur le serveur : tout changement passe par Git.
git add gitops/… git commit -m "…" git push origin qa # → Argo applique (sous ~3 min)
Le VPS devient jetable : re-provisionnable en rejouant A → F. C'est tout l'intérêt de la démarche — le plus dur (découvrir les pièges) est fait et écrit.