From 224c06041e4ea767f71c27859d04e976aee58370 Mon Sep 17 00:00:00 2001 From: ALI YESILKAYA Date: Tue, 7 Jul 2026 23:20:33 +0200 Subject: [PATCH] feat(forgejo): Git self-host en miroir de GitHub (git.funklab.online, SSO Authentik) (#96) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - k8s/apps/forgejo : deployment (image forgejo:11, config par env), service, PVC nfs, IngressRoute interne (git.lab.local) + publique (git.funklab.online + middlewares security-headers/ratelimit), Application ArgoCD (ns ai, recurse) - base PostgreSQL `forgejo` sur storage-01 (rôle postgresql) - vault : vault_pg_forgejo_password + vault_forgejo_oauth_client_secret - doc admin/k8s/forgejo.md (archi, OIDC, création du miroir, pièges) + index + CLAUDE.md GitHub reste la source de vérité (pull-mirror lecture seule) — ArgoCD inchangé. Co-authored-by: Claude Opus 4.8 --- CLAUDE.md | 5 +- admin/README.md | 1 + admin/k8s/forgejo.md | 126 ++++++++ admin/k8s/public-domain.md | 1 + ansible/group_vars/all/vault.yml | 334 +++++++++++---------- ansible/roles/postgresql/defaults/main.yml | 6 +- k8s/apps-of-apps/apps/forgejo.yaml | 24 ++ k8s/apps/forgejo/deployment.yaml | 99 ++++++ k8s/apps/forgejo/ingress-public.yaml | 24 ++ k8s/apps/forgejo/ingress.yaml | 15 + k8s/apps/forgejo/pvc.yaml | 15 + k8s/apps/forgejo/service.yaml | 11 + 12 files changed, 498 insertions(+), 163 deletions(-) create mode 100644 admin/k8s/forgejo.md create mode 100644 k8s/apps-of-apps/apps/forgejo.yaml create mode 100644 k8s/apps/forgejo/deployment.yaml create mode 100644 k8s/apps/forgejo/ingress-public.yaml create mode 100644 k8s/apps/forgejo/ingress.yaml create mode 100644 k8s/apps/forgejo/pvc.yaml create mode 100644 k8s/apps/forgejo/service.yaml diff --git a/CLAUDE.md b/CLAUDE.md index 5b53f99..6ea0b10 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -127,6 +127,7 @@ Variables chiffrées dans `ansible/group_vars/all/vault.yml` : - `vault_authentik_secret_key`, `vault_authentik_redis_password` — copies de sûreté des valeurs du secret k8s `auth/authentik-secret` - `vault_wireguard_server_private_key`, `vault_wireguard_peer_private_keys` — clés WireGuard (serveur + dict par pair) - `vault_grafana_oauth_client_secret`, `vault_openwebui_oauth_client_secret`, `vault_argocd_oidc_client_secret` — secrets clients OIDC des apps du hub (= secrets k8s `monitoring/grafana-oauth-secret`, `ai/open-webui-oauth`, `argocd/argocd-oidc`) +- `vault_pg_forgejo_password`, `vault_forgejo_oauth_client_secret` — Forgejo (Git self-host) : base PG `forgejo` (= `ai/forgejo-secret`) + client secret OIDC Authentik --- @@ -171,6 +172,7 @@ k8s/ │ ├── ghostfolio.yaml │ ├── openalice.yaml │ ├── finlab.yaml +│ ├── forgejo.yaml │ ├── authentik.yaml │ ├── guacamole.yaml │ ├── monitoring.yaml @@ -183,6 +185,7 @@ k8s/ │ ├── ghostfolio/ # namespace: ai — suivi de portefeuille (ghostfolio.lab.local) │ ├── openalice/ # namespace: ai — agent IA financier (openalice.lab.local, back-end finance d'Asa) — ⏸️ SUSPENDU │ ├── finlab/ # namespace: ai — dashboard finance + console Claude Code (finance.lab.local, /console) + toolkit +│ ├── forgejo/ # namespace: ai — Git self-host, miroir GitHub (git.funklab.online, SSO) │ ├── authentik/ # namespace: auth — annuaire/IdP OIDC (auth.lab.local) │ ├── guacamole/ # namespace: auth — portail consoles SSH web s01/g01 (portail.lab.local) │ └── {external-services}/ # ExternalName/Endpoints pointant vers storage-01 ou gpu-01 @@ -202,7 +205,7 @@ k8s/ 2. Créer `k8s/apps-of-apps/apps/.yaml` (ArgoCD Application CRD) — copier `n8n.yaml` comme modèle 3. `git commit` + `git push` → ArgoCD prend en charge automatiquement -Namespaces actifs : `argocd`, `infra` (Traefik, MetalLB, NFS-provisioner, registry in-cluster), `monitoring` (Prometheus/Grafana), `ai` (n8n, open-webui, stt, searxng, ghostfolio, openalice, finlab), `auth` (Authentik, Guacamole), `sacrifice` (jeu FPS — déployé hors de ce repo et hors ArgoCD, cf. `admin/ops/etat-cluster.md`). +Namespaces actifs : `argocd`, `infra` (Traefik, MetalLB, NFS-provisioner, registry in-cluster), `monitoring` (Prometheus/Grafana), `ai` (n8n, open-webui, stt, searxng, ghostfolio, openalice, finlab, forgejo), `auth` (Authentik, Guacamole), `sacrifice` (jeu FPS — déployé hors de ce repo et hors ArgoCD, cf. `admin/ops/etat-cluster.md`). > Les services du namespace `ai` sont exposés via des **IngressRoute Traefik** (CRD), pas des `Ingress` standards. diff --git a/admin/README.md b/admin/README.md index 704b175..b679044 100644 --- a/admin/README.md +++ b/admin/README.md @@ -66,6 +66,7 @@ | [k8s/n8n.md](k8s/n8n.md) | n8n — automatisation, workflows actifs, credentials | | [k8s/open-webui.md](k8s/open-webui.md) | Open WebUI — chat web, backend LiteLLM | | [k8s/ghostfolio.md](k8s/ghostfolio.md) | Ghostfolio — suivi de portefeuille (PostgreSQL s01 + Redis) | +| [k8s/forgejo.md](k8s/forgejo.md) | Forgejo — Git self-host, miroir de GitHub (git.funklab.online, SSO) | | [k8s/auth-portal.md](k8s/auth-portal.md) | Authentik + Guacamole — architecture, déploiement, accès Internet, pièges | | [k8s/auth-portal-admin.md](k8s/auth-portal-admin.md) | Portail — administration : utilisateurs, machines, apps du hub, révocation | | [k8s/public-domain.md](k8s/public-domain.md) | Domaine public `funklab.online` — HTTPS Let's Encrypt, apps exposées, ajout d'app | diff --git a/admin/k8s/forgejo.md b/admin/k8s/forgejo.md new file mode 100644 index 0000000..ce7b2bf --- /dev/null +++ b/admin/k8s/forgejo.md @@ -0,0 +1,126 @@ +# Forgejo — Git self-host (miroir de GitHub) + +Forge Git **Forgejo** dans le cluster, exposée dans le hub (`git.funklab.online`, SSO +Authentik) et configurée en **miroir lecture seule** du dépôt GitHub `Funk-lab`. +GitHub reste la **source de vérité** (ArgoCD continue d'y tirer, rien n'est modifié) ; +Forgejo en fournit une copie locale synchronisée + une UI + de la résilience. + +Namespace : **`ai`**. Base **PostgreSQL sur storage-01** (pattern Ghostfolio/n8n). + +## Vue d'ensemble + +``` +GitHub (Funk-lab, source de vérité) + │ pull-mirror (toutes les ~10 min, HTTPS + PAT lecture) + ▼ +Forgejo (cluster, ns ai) ──HTTPS──▶ git.funklab.online (SSO Authentik) / git.lab.local (LAN) + │ + └─ dépôts sur PVC nfs `forgejo-data` ; métadonnées sur PostgreSQL s01 (base `forgejo`) +``` + +- **Sens de synchro** : GitHub → Forgejo uniquement (miroir). On ne pousse pas depuis + Forgejo. ArgoCD n'est pas touché (il tire toujours `git@github.com:...Funk-lab`). +- **Clone HTTPS uniquement** (`DISABLE_SSH=true`) — pas de port 22 supplémentaire exposé. + +## Composants + +- **Deployment** `forgejo` (`k8s/apps/forgejo/`) : image `codeberg.org/forgejo/forgejo:11`, + config **par variables d'env** `FORGEJO__section__CLE` (pas d'app.ini versionné). +- **PVC** `forgejo-data` (RWO, nfs, 10Gi) monté sur `/data` : dépôts git + `app.ini` + généré (dont `INTERNAL_TOKEN` persistant). +- **PostgreSQL** sur storage-01 : base + user `forgejo` (rôle Ansible `postgresql`). +- **IngressRoutes** : `git.lab.local` (interne, web) + `git.funklab.online` (websecure, + Let's Encrypt, + middlewares `security-headers`/`ratelimit`). + +## Secrets + +Vault Ansible (`make vault-view`) : + +| Variable | Usage | +|---|---| +| `vault_pg_forgejo_password` | Base PG `forgejo` (= clé `pg-password` du secret k8s) | +| `vault_forgejo_oauth_client_secret` | Client secret OIDC Forgejo côté Authentik | + +Secret k8s (créé à la main, **hors git**, comme les autres apps) : + +```bash +kubectl -n ai create secret generic forgejo-secret \ + --from-literal=pg-password='' \ + --from-literal=secret-key="$(openssl rand -base64 32)" +``` +> `secret-key` chiffre les données sensibles internes de Forgejo — le fixer via le +> secret (plutôt que le laisser régénérer) garde les sessions stables entre redéploiements. + +## Déploiement (ordre) + +1. **Base** : `ansible-playbook -i inventory.yml playbooks/storage-01.yml --tags postgresql` + (crée la base + user `forgejo`). +2. **Secret k8s** ci-dessus (avant le 1er sync, sinon `CreateContainerConfigError`). +3. **Merge sur `main`** → ArgoCD crée l'Application `forgejo` (~3 min). +4. **OIDC + admin + miroir** : étapes ci-dessous (config en base, hors IaC). + +## Configuration OIDC (Authentik + Forgejo) + +### Côté Authentik (UI) + +1. *Providers → Create → OAuth2/OpenID Provider* : + - Name `forgejo`, flow `implicit-consent`, **Client type : Confidential** + - Client ID `forgejo` · Client Secret = `vault_forgejo_oauth_client_secret` + - **Redirect URI (Strict)** : `https://git.funklab.online/user/oauth2/authentik/callback` + - Signing Key : le certificat self-signed +2. *Applications → Create* : Name `Forgejo`, **slug `forgejo`**, provider `forgejo`, + Launch URL `https://git.funklab.online` +3. *Bindings* → lier un groupe (ou ouvert). Membres de **`lab-admins`** → admin Forgejo. + +### Côté Forgejo (CLI, une fois) + +La source d'auth OIDC s'ajoute par commande (config en base — pas d'admin préalable requis) : + +```bash +kubectl -n ai exec deploy/forgejo -- forgejo admin auth add-oauth \ + --name authentik \ + --provider openidConnect \ + --key forgejo \ + --secret '' \ + --auto-discover-url https://auth.funklab.online/application/o/forgejo/.well-known/openid-configuration \ + --group-claim-name groups \ + --admin-group lab-admins \ + --scopes openid --scopes profile --scopes email +``` + +Ensuite : `https://git.funklab.online` → bouton **« Se connecter avec authentik »**. +Le **premier** utilisateur créé devient admin ; via `--admin-group lab-admins`, tout +membre du groupe est admin. (Break-glass sans SSO : créer un admin local +`kubectl -n ai exec deploy/forgejo -- forgejo admin user create --admin ...`.) + +## Créer le miroir de Funk-lab + +Une fois connecté (admin) : **+ → New Migration → GitHub** : + +- Clone Address : `https://github.com/Alkatrazz24/Funk-lab.git` +- Cocher **« This repository will be a mirror »** +- Le dépôt étant **privé**, renseigner un **PAT GitHub en lecture seule** + (*Settings GitHub → Developer settings → Fine-grained token*, scope `Contents: read` + sur `Funk-lab`) +- Owner : ton compte · Intervalle de synchro : `10m` (défaut modifiable) + +Forgejo re-tire alors GitHub automatiquement. Forcer une synchro : page du dépôt → +*Settings → Mirror Settings → Synchronize Now*. + +> Alternative API (au lieu de l'UI) : `POST /api/v1/repos/migrate` avec `"mirror": true` +> et `"auth_token": ""` (jeton Forgejo perso en en-tête). + +## Pièges / notes + +1. **Miroir = lecture seule** : ne pas committer dans Forgejo, les changements seraient + écrasés au prochain pull. Le workflow reste GitHub (PR) → ArgoCD. +2. **Repo privé** → PAT GitHub obligatoire à la création du miroir (sinon `authentication + required`). Le PAT est stocké chiffré par Forgejo en base. +3. **Config en base** (source OIDC, miroir) hors IaC — comme Authentik/Guacamole. Backup + PG = gap connu. +4. **`git.funklab.online` déjà résolu** par le wildcard OVH + dnsmasq split-horizon — + aucun ajout DNS. Le cert Let's Encrypt s'émet au 1er accès (HTTP-01). +5. **PVC RWO + `strategy: Recreate`** : un seul pod monte `/data`. Ne pas passer en + plusieurs réplicas sans stockage RWX + config HA. +6. **Dépannage OIDC** : `kubectl -n ai logs deploy/forgejo | grep -i oauth`. Redirect URI + au caractère près et slug Authentik = `forgejo` (sinon discovery 404, cf. auth-portal). diff --git a/admin/k8s/public-domain.md b/admin/k8s/public-domain.md index 3aabc41..a2de2ae 100644 --- a/admin/k8s/public-domain.md +++ b/admin/k8s/public-domain.md @@ -99,6 +99,7 @@ Authentik (`https://auth.funklab.online`) et directement par leur URL. | **Open WebUI** | `openwebui.funklab.online` | SSO OIDC | `https://openwebui.funklab.online/oauth/oidc/callback` | | **Argo CD** | `argocd.funklab.online` | SSO OIDC (lab-admins→admin) | `https://argocd.funklab.online/auth/callback` | | **n8n** | `n8n.funklab.online` | **login natif** (SSO = Enterprise, indispo en communautaire) | — | +| **Forgejo** (Git, miroir GitHub) | `git.funklab.online` | SSO OIDC (lab-admins→admin) | `https://git.funklab.online/user/oauth2/authentik/callback` | - Chaque app OIDC : provider Authentik **Confidential**, client secret archivé au vault (`vault__oauth_client_secret` / `vault_argocd_oidc_client_secret`) et dans un diff --git a/ansible/group_vars/all/vault.yml b/ansible/group_vars/all/vault.yml index 8bbfd7f..cc99c1b 100644 --- a/ansible/group_vars/all/vault.yml +++ b/ansible/group_vars/all/vault.yml @@ -1,162 +1,174 @@ $ANSIBLE_VAULT;1.1;AES256 -33356635376530636235353635313534333830323835333938316363643235346362643961623139 -3935353363323966396163636138336532643464633337310a656639363665353962323230623930 -61663431623565396361316366626333386565386436356535653439653836313533313734613362 -3433333966396264360a623331656633646531356466376638343533316233386363323564653231 -31626133393266623239666138623035633033356239326233613665663732356433623333393033 -64333565353039633765633331636463666331376661636635363166306566653364386365366365 -61386165323533626365646338613263373934333637616234623664356464323739323066643663 -31613438656233663038363331373439323863393662356365633036646539323336643238363963 -32316631366335303565366232353461326135396632656464663238383265393366653961313463 -31663533343035323334313764653933343064363963343131363732376533383964616336363037 -61353836356165386564366662653063353038666364383462343066663233313338303237656564 -35366236363032373661653738323933396235343063643361613033333136386637336664316438 -66313164623466333561346564396333396662353062353630386465633366383061613937346235 -30623230666563383765333139613665613866633735613737623636306134343534396563343233 -35383038633531326339326662623062663738663464633739333636306138373534346262353963 -31363466333534383565653536343535636232383135303934306164393438653133323866386439 -61383264616164376166303065346566326538343835383934613030356562363930313539333034 -35386561303033356562303233353431623461343933393638643035383237623838386161663964 -31646631306339373061613137366138393839303834376338383330636364653037633439343635 -36323865386532643532393965343431653536633538616633363462383939343132656564633435 -38343038363164363262376438376231313232356532396331643562626231353366373031336363 -37386538613138353262313139656566306231393735623035326130613433313738386262653462 -30303837376662633062653636363763643466383230333137633039313766636561343839633962 -36613533386437373266343732383630633531636537326136393364633939366435623935623634 -31386137396339636337346666393366356534613630613032633232636238343165323965313038 -39623735303666626534353663623033643462656362396634396464636565346133363063363237 -65303938303665393462313832316161396235303164616162356431613135313535396334633965 -34333535363961663235313265623265636366633430343066346134386634393031636338353137 -61656536346561626139616639303866623036363331633833333864623665313539333064613464 -35333564643032653465356132643439366633323331633535353731663431663261613232313433 -35383763643737653661373061663336666163343531363331373465373565343766356363376137 -61353235313838376264303666393461653362386163336662363561646636343739303039353264 -66363664393331376233656639653061663261623439393765316634616162376630373931643935 -32666533326136353538393937633166396233633333343533613465646330323964653835653962 -65333231366436666538343739373436333462313664643963616434653963373063386330356266 -37646663613133343161376538663735326630373436623464366263386263616434636639623961 -32396666316331636361663761393830366538383935623631633333393662356438336565356637 -64663465386232656131633639643639303036626434386239656662353436613864346133323366 -64303035363764386139636365393764363264646534666336663135313739336239646534643536 -62646637623032313132386564343862393062643938346237653563643331316361346236323761 -61663635303139666232383862653266613431323932343165396238623863313230333233363736 -65303566373932363464343965343362633335623533306635396564653836303036303833383164 -32386364333763346461333932663931343134623336303431653131326633373933376461393436 -37636464626561333932393934346532613362626131303133393234643566366337623861323739 -35643139323031613565353331333930383733383934653461383866336330356665336435343663 -65386261393433343131623433313233636439386461346266663439393231613361333363356337 -35316132336265326235333938333038663335306532656630313231373034613634623865663236 -65663035666563663763633062356436653065613661626363336230306334336637613665313064 -36333765616536613236306433633563336164333463356436663434366537623339616165373338 -66363436393766336562626164303164383761326439396339343030376630353033653738306538 -63653638646439363535633261313862616639306530343963643332353931313932613238383863 -63323466373465333038353330623538353163323365323262376361353239663565313337306237 -34353364303139386437663635626338313334386263363562306537363864623264316135613230 -35386666353066653063636662303333363531373833633761613034323766643662626237663166 -30636434663033646364386266623566323730633939656230653665333637613565643636633133 -63323064656335363164313234356264303333323332663338346166336538623463363263623762 -33373833303638373937636633343334663861643966333861626335323862373335643434643533 -37653436653230356534613461326139633432616261663764643432616239333162636466663366 -66393162396165383231653362353031383763333530343961393064393432653266663438393932 -34313331353561303937363336633862623038303332396337383037386338633938383336613232 -63313363363434343536656432616135336561386665353932656465336465623262656465326634 -64626661333335663132363437333265303161656165336336376461623435343836656334326464 -32303961326232643235303334376432613330363735336237633339346264623336663262306437 -62396634316134393563343564303636656464666133393932313430383036323765383039356437 -36633836386133303962356435306362643137623936323633396463643665363262353837363234 -39663131383836313666613963353034393131383036656235626465386365666463653536303162 -35343333643533623831636665333364306563306435373737386137633738626138386262356166 -31356236366334323364623636393138363832306537363764353939623032373736353961313730 -31383165396635643930393266313339343861346635663034333266616461613537653635653263 -38386139623935373933386232393231643462383662626534323837333638663563663236396661 -66653638373137633031363436633961333066666531636661316266646639336266636339326637 -65363864613139633738633936366237643837396537323034363164616337356439366537313230 -30656163396239353562316163336362323439336537383363306664373439643634353633393766 -35393539636464323866323265663262366533353066316234353566663432633733656264656239 -63396631623139303462373065346564613734373831666536323934373537383563303035613864 -33373662316637323161386563373730633035636662333135383031316233333339643831373963 -32623935313236613636366235616466386239656238636461343065656263623664356365636339 -64396263316438343836623962666139386539313330353732333133353661326531343061316638 -38393464366466306334376461623364623731643235626537323530336465383761373438636465 -34613339326136336365326563306361303734343363646166353233343733343830643632613931 -37306639343663323830323837393533333433313639376130373731316565303039653039353836 -36333530323038326665303530626431376639393035636136666332326662353164303234626134 -30626265336230613138333337306130306563353263613562323635643036396361623336353963 -61643562643437373263356565643836643665303233616434613436333266626137336230313634 -61653564303161616565636531336133613436353230383266313961366137383332623532653834 -62363039373762633063666563303262303062616533666136323865393739393337313936376537 -38356436663135646438626561316261646630356437333365656666646336353334333531663035 -35393861313764333366653733356630333332383239616639393630376165333232313239643537 -61633466313761333962666565373332636632343438396538373161666562623461363136316137 -65666463396131363235333761336237326638626461383037636630623331353163363163643665 -63306666613965613134346534343931303137353734653733386132326431626635323032366664 -65623539363764383864323263363634306364383732346632366437323264616236333330336534 -65643633646561393632633936663666613266636333656665376164633061653731383236316339 -65343466326535613432656439356332376437353264396630373965313061366137323431306134 -30616162633961386331323639613634623638653335353637326537653831346438333331336639 -61373837666265633836613133666162613362663763396166613636333536303035663836396234 -66623436343436656433336466663637353938333230303435333265356266303661383666396566 -39383438623565393431633431666461613363306637623764313766613335356337376638363335 -34313066366362643363623066376334643731376336393965636431616466386335623032613631 -36343134313637366539326361643637623738393265663763653766373066353465363764366564 -33363435343138613535356134323831313731356530353834393966383962313162313835336631 -33353332323961316230663738333038633230333064353264366333393330396633386337303436 -32613537386633616263353566373635626663363134626163646561363135333865633063666332 -38656234333838353863666664616133343532656265656662303831353966663536333264356232 -39353962353033626138393934656635343638386637363066346265653863656163376337376138 -34656132353163356132666532656331333138396662346263393636333439626538653439666633 -39626630646536613164393964373265616565356265343337346539313839383464623763663633 -32336639353335663634336336363061663438653764613435396239316164306439363234316565 -66343161646562366364656331313331306538636631323631666237633531316430643366346330 -61313230616132613465646635663936393532363538633435626164316330326462333162383936 -35336335306434386438623735366631613363373735303932376366316536623166356332386635 -35343165386265643463623464303835396161363031343032303535643535393334313761653834 -62393836353139636134643066626633386138616435303631303037646265393332373732623866 -61653230343233343230353137356163343930663530326332383232323135666562633431633563 -36383265326465393766633964623862393732353031343831636239383333633437616138383164 -66306633646435336336643533616232656666643937363534326466663431626261623363623934 -33623334643165383765636637353536353331656235613664326135653832393735313337633264 -62666334363033356532633965373630313364393738616561643039316662613239323965306266 -64326364393439623364363931656332613666663434393263623661653564353839613664396361 -32306231323836303066316564663633373036633933353864663134663531623235343732316332 -64663535363663646264373064383038643462393039663334656436633336346335666237306535 -66303864353034346466303739376537336565306539356163323462333134376537633563353763 -38333365613932656630386164313065346537363563323637333066383765386339643762326631 -63353330663962313363356536303434643538626632323539653164353962323137623830303039 -32316131623636636638346137653364343761306236633835316131653964636431666432636165 -62636532333034353061393565333566326633306135313234373134666633626461393264393533 -30363531333962646234366131346631373965623630663034633964653939306632636233613930 -35636264326264383463616263353136666630343263616138623831333166363065326435303732 -39616236313736373665363739623730383530643433663537663366633964333263313130656664 -36646630306139363431636638383261336162333631396564343761396364336564396563623934 -39323933393466373134393431616238623665383934326431366432643866303136303165646438 -63643765336361313237313262623238326566636566633066383166393265646162653362326533 -36633030613739343666316131373336626362373563366263353532343034373161326334386438 -64623962303663356532366363663132333465616266633633636437666665316665656662373166 -38336436363761356438326166353565393266323535613065363432373362336235356234646463 -66316236313131303037666435623332306638393465383066623932376337386461646562636364 -61366530366434626461633862626131626266303733616265336631646366626161643336383264 -62643135646530626436393934616539343335343966643034396436386434323337613731393631 -35623231356231306635383337333733306466653137306332396439333566336338343365343236 -38613665373663333766376332353139303435643538626239626138663135656464386634636265 -64646163653463623539396362376632613563626663626637626363363539356466653565646436 -36396136396132333363623735643334303937656165353538396562663265363530663463613034 -62663735636135616665326164636266393831313136333764363861366233373332623832663232 -63643232616261396562353339373232336465363838353237613737393332353333303265316237 -32643465623265313862663663643937623433373434643932623032306630383932313934623331 -38646638303532366433323364623563633030646439363532396464336264336531613561626339 -38643735303964323564313237633932303237636331393462643538333230393933313936373832 -63386461323235636161326165616165383165636661366632323939346664393763633763636534 -30656335666664616662333765373339303463386435666635656438313338636165383837626362 -62656535383761306134643363356534343439373938653538383237353361393031393361643734 -35333939383361333538333636323237663537333530613462373834376438316261356237656262 -66626362363430336161323666646433326662623837333631393139326134646531353265383739 -63366234366539366661653231393532336639646365616234643761313563646661393834623664 -66636361653139353763316437373735663664393134633639623563376566636164366461386231 -33346666633762663530663931373364386435393734616230636430653738323838613366633239 -35343334363634383462336463303661356130643939396361623532343538396539336634356335 -61356638353764323537626536636665623262626439646139306263653733386634616239383163 -36313630373464656433303562616331336533633837356433616433643438663762303635323538 -37323462636235643132636462313739306561396434303430396534366637363431366164313538 -37653862363261396430366165323735613165346362653037353963393135376239373339303939 -34623364396234646465336432386137356436373933383066646633663831656130 +65616339323763323038653233383731626135386338376666663030636635393861363238356239 +3436656261656532396538646432306535656631313433300a663637353565653232323735343164 +33666439326232323631363339333434353165343633356439316465343233363939366664373839 +3263326332663133380a303933333362613532343533643832313033643435643661353664303265 +37363231613436343661653837376638653232386363333434393835396137373839346162623335 +36343530346236323532383063346361343636626438363436346330616361396532663964636661 +32643865323934316237393561336661363232623066323634623465653232623934373437623661 +39656332373066303332343035396662323434363665313966633863343865356332393033323235 +63343130623133383532306266633832623931653532356434613664396131376236383464303536 +34363138616562336162343061336463383937346231313930623463393631633132373664663563 +65343463646238373231316431316365323166636335623737313635623166306535353738343438 +39326130333837323036653234633136353961613638646261633339663435613837633036343533 +34336532393465356431396635323637666334633638386135373732383133323736663961343037 +37326133316461313961633238326532303863623437623539313038373736613831376464316461 +35396532333238356466396332306662356164623836643561333836656333393937313936626264 +63383837326131373864313035343231393836643862393332366663343662663638653832616337 +66343639663161623139393836646161333438393030646536396266323838383230333934373735 +37356331333165663163613231616662626434626466336266366339663962666533363065303335 +63333533313234336530386536336139363563333166303265343934613136336637306530333762 +62386263323737363964613061346363333639353665353437616563396238623738613038653232 +31616237633065383232633737393631656261363930306364383033343330356365333564663037 +37623139343138356539653365313461313139383365383834363139623163613235363833646233 +63636231353666653832376434623832356663383464343466323432666137633432653236303134 +37666132343863653832636130333261633336386463386437656131646230613936636438393436 +36613237616232373961323566656131663834383338643561353066366563363038313436396534 +33366565333761316634353666633836383736383732633534363633353563353666363833663561 +66616533376563633537653735383061346135373339313833663363393638313035303435633732 +30353136646336303931363061303261356532366562303233376139356664386130656538653937 +65623437376339346232326238383462306237333035323861613561613730623862396134616663 +63626536303063636361653833616236343337383630396265623863666236613733306631653938 +35663563313461643331656335613336376661656130373636613932363832646330353631666465 +61633430616564393461343737336638303863383264346338666265393834636539626336386435 +31646361656637316261613433356237626538663464316631396231353330373934366362353765 +33356639353130306635373130656235393838663732323539386366653831306135656531316130 +35653832323361306332386666303136326361663262666264643362653464623661643663346339 +64626464363562306530353164303435336633383330343566363766396638643865633165613439 +37393939313134323633333066303334623266343330633265613333666436623633383637616137 +38633135356430653631663838376631613866336436303434623262623531643136666364313839 +32323161346436373731626235366535396238663964323036636464623131663433366565393465 +30343465393034343462373164353933653334383364353065373561323131663238333264383736 +30336633636636326262306166636430663062656534656462376337343564646637313237613933 +63383836666361316566663632386162363431373862316366663333326366306461303330626430 +30643831393233626432623833353839346239633964656339383161626165626539313164306337 +62643762663535633162396331633631663437306561323139383332666334343336306561323238 +39323939326165663063613135366665346366376336326138323433383137376230626365313165 +63303738326238323334383165666536636661363262393330303663643637653130616134656336 +33366663656339626163363664363639363039363131386361613034336337313434363333636235 +63656463623938626237343666336138353937633836643561313732383566663436306261323932 +37383962383630346237326366633831666139313261383635303939643131393365366331643039 +30383036303262663639623239663130353739663334333231613830656136616331383931393165 +30333365303638306262396231616536386534663563383636623037613631653836366136376130 +34333733353162386435373861343131326233626666643433333135323337303864386538316163 +64316265333766613536343230313362316565626166623238623533303636366238633465656632 +64373438306662656430623863366231383863383765643666313465376230333334623932323038 +36323463303064323065313034346330333331646139363438353765306530356534636335353965 +62616530333433386632613833336162396236616166336230653663376262323331386637656639 +32313233613965643264656661646138343864356631343134303232323337646234633161646235 +35666361616231346165383438366138383361663830353266316162353034393435313963303462 +66333061306234356637323063363563393761633838383165636135383663643162613539396538 +65386234303565643665656333363631373462356334636464363130396633346231633866306638 +35663666656132353261613664316632393832616634643066383339356239313033663866323837 +39306532393164326537306237396233393264323361366638306162356236623864666263336432 +66666261383662396632663239313637393736323935363164633438303439653761363631313162 +36646466613131343033623034316232633135653637363832656531336638366536386563623065 +38643639363439623236313632626231363134303431643137323964363164336131656234396564 +32336234323466333665393932623064396165643463393039303764353565623466323632616635 +65633963353436333335333933623833343935303232393061616333626430303333313938336130 +66666534303638616363376364393538356365386363316264336332616166373136383935376639 +61653166386331323232323261316234323139313365633737613163373963343239623165366430 +33653765393765373632333365326333616665643564666630386530626561346465363665336166 +39663333393838313964653131653733653362366238633939373063346537396666373838343462 +63303365376235626564376236623337336435303832623665356633613131366161643131626533 +37306137303233323732326430333861336238376136336264626162363734333337366139306563 +33363862393935636635376638376162376164663766356135663239326230636163313530376366 +61316637653139643664356635373233623165616163313431653834663565363838666538373239 +39326437363164643430353836386633306666633234373530663762343830303833316538663336 +65383131306232363637366161663861633034626665386266643630333131353537653733336262 +34663337666631373233333137353862646137643434333336666466656136623433333237333031 +63613930663465366430316363333663333661306139306666613239633163323963653535346632 +31643262623265376130613034306536663465613938323233623537666437656466353538373131 +31373033666430356630373132323736663432353131316361333935656162373037303066666135 +65633830383739653131633530643263616562363134613963333537353836376535363763373865 +62613435363866373432306330613534353064663530336136393334633633326232383039353836 +62613831376237363035626330393431313338303133336433313534323662343131663464633235 +35623737653562643761373836666539633431356235313738653439646230653231383465373065 +38623331643732326138303634393735386162623865303030616265343464323835386563393337 +63383064373331663237383766376566316531373865363739636430623562623862313862353433 +62373937393965663130393164353336633665666534643766613662653430663537666262333930 +31643961653634663236353632623164653635663232656364303966666636353066333538323563 +64383261373336393933613539393066616563343262393139326139643462303134336565663730 +30373939643138613631663938313765653331623536313337393263316138666336343939366637 +64636437383063616566333566303430336565636635316461646364373838323466366564366263 +36613864336161346363303364323538393538666534666639396631653666346237333264326165 +36376238653339326535326437386566336535383333663166643135353137383135636161623731 +37396638353933386234663361383636353135323462303332363038393261363739383265656632 +65366462623330336162353035623464616366303462633136323530613866616336316430623164 +31633136366233653632363935353766646265616631363362396132623061613339383637313532 +31376635373936393664346265613035346665666239623133346230653861353831373464376366 +64653231626535626561366466383763396436646635393739616566363934306331613239373436 +37303437356435363762613734363431353962666335373439616166623262303038313231316638 +32316130376230653637623833366639663361326362333638353737623266643832386433343038 +64386165313732656563376136623234393362633765386639326139336438323034393133626664 +62323134373635346566306631326431313165663034313563393634343261366438353436396161 +39303938663132383431306438303663363131376138343536633433303330346434373231346661 +64636635326565386361656634346539343634386465616538343337366462303061653934343534 +33346562353238326334396266333661656261633230623538363062386565616530366565663064 +65626665383637323438373261316465326130383939373162393763363739623835386530663261 +36616238633262316337636566353033386536343434666238666264366232306231633131356165 +62393263386137346563346664363934303565313561393237343761306263653633383765633562 +31636237373038393937346532653465626339663137383935643065303762353338343763613962 +30376361333463616539363435393133303736323861336364343138306436393638386162396464 +37356138323139313938663961613261343439383335323631646237343762346434626130643061 +32303163656638313739613637633465626334356433343039303865636636623530643135613631 +36333832646337313162626139626335626362653834316138353232666663303863363637343665 +63303239666237363462373835616631356564666163366365663666303562633633336638636538 +65386134633566323365366566386232333736386463313564663536613334376162626261356139 +31663865333565663238386461666634623732343662326261383066346435396336353566353433 +32643234386139313634383962613030333535623737333364343132656163346530616363653062 +38333236333430373266343533313066313064363135356535613231373936653233353563366334 +30303166633432316461656566626131643564663661343066316366623962646366376565396334 +62613631313932666238373066333130313961663363656265653637353737306336373666656665 +61366439393266326666393332633662316261646531323835613764663833643164653632343431 +63353836623337616566376663336236373735336263636232616163363439336433336233656435 +62376633616630383361633738363961373431393532366130316332396663303638306164653532 +33313332323934386430383764653832356133343232643961613336653266616661663337373230 +30333063353930353236323037366237613537326432396538383737376230613062636363666337 +35373366656130326663336165616232366436633037386163306363303164383539386430643464 +64393262323765373032393565656663353837376635366339396436386330656235646462343038 +34386530343638313039633637656430663231396135626563363130646530653535616461656335 +63633866633365343835343364613036623037653130633335333532663639663135326565396133 +39393232383863666237383662313163396233613432343864366666313861383632626566626262 +39353361626265636638663263643230313465666330396562613134333338643630613836313631 +38616339393337613233373931393362623063626262663230393934653663643737646266633935 +34353130633066383462643431336164316330646537306636373234386230306161316135306265 +30303562376662653363626561376236306461323264636231343135353138666261333366336632 +63326137613362623736653734313738326362326662306663346539306461333637343236313536 +66663361303763636637373337373735653963393863353764643863633664313461663935356663 +63383934653266386165613664626130626231613437633437313730346634313730656661623462 +32353338346531656432333462326439363733626234663439643761366463666634333738656633 +63306363343539663834656639356537353435306437613331383163643535303562653865366331 +62616161663465653565376264313764633861313066356630613737316262626330623261326636 +63613564656336316538633536646635623663613931616538336363666636313561663931383632 +36366636323562643865633366313439393463383261663637386134643033326238613764623063 +35656466313839383563346564323733356565336131376438613230633138663464626336326163 +64326439356633393935666338383932373137333964323532333337386562353033323563396533 +37653764613431643135396263323963633063316230373065373737396430333535626430343366 +32303666663634383833613230373134353731663630633461326238663165613939393338396338 +63313531363530613664613833356134643263323735663563643966343934643662373636346130 +33396339636461343163396161366433373739333865336331333638303939333862383131353630 +62646336623936366534363963656464626564646133663337373262643732393432643265306135 +30363833333432666463663465666162336266363365303438396564616466343635343337383865 +62353530333739656531313938666630366138393864646438396435343931303137393232386166 +32333066626437323761336361373934383933303131663435376131306333343066633265343461 +64633563373037646666656632386564616464373864396335363435363964323037646233353731 +33633335373534663737323333373633646337633661623537643630396130373662656239373338 +33303832653537306562666661303862313235643735333539303863653934626363646337663932 +64356262303938353766383064346235376235663665636265653939656563646335613064306563 +61316266643635373637626436393634636235356136373835633532356237326232386235343235 +38366632346338356239316162623062303831383261383233396233326335656462366334396161 +30373966643832303136396266623436363539633335653565663965393838383933306165653034 +66636233656535626138623264366230343061663365353761353234373365666635383938333765 +34396330646332323633393230633235393736623962633538613764386537326232353863613639 +66356434623964386339393039373933326563383963383639303264633235356630383235386331 +61633534626366306537346438313264316536616138316336393737663136616230366161623763 +32373238373538396339373939663336323966303062316131396364663738353363396438346635 +30643535643631656534306335666264346533626337333233663536373965343063396138313564 +31373363346339333932376339663830613465633431323933303666643766626139376566616364 +36616162303530326461616335663336313231653366616334623264373439636463613061303337 +62346262393633623636303836383264636139326333353061333330663635666366306432323630 +66623962303865383966343766333065663862393662623237363134303733303339303930663237 +30323065343538643038366533613730646566396564656334346632326334613732383232393934 +33336131393839613234333438653062366335646362376564353964376361383135643961613563 +3437 diff --git a/ansible/roles/postgresql/defaults/main.yml b/ansible/roles/postgresql/defaults/main.yml index 16876fb..6c1d7b0 100644 --- a/ansible/roles/postgresql/defaults/main.yml +++ b/ansible/roles/postgresql/defaults/main.yml @@ -13,7 +13,7 @@ postgresql_shared_buffers: "256MB" # Mots de passe dans le vault : vault_pg_hermes_password, vault_pg_litellm_password, # vault_pg_openwebui_password, vault_pg_n8n_password, # vault_pg_ghostfolio_password, vault_pg_authentik_password, -# vault_pg_guacamole_password +# vault_pg_guacamole_password, vault_pg_forgejo_password postgresql_databases: - name: hermes - name: litellm @@ -22,6 +22,7 @@ postgresql_databases: - name: ghostfolio - name: authentik - name: guacamole + - name: forgejo postgresql_users: - name: hermes @@ -45,3 +46,6 @@ postgresql_users: - name: guacamole password: "{{ vault_pg_guacamole_password }}" db: guacamole + - name: forgejo + password: "{{ vault_pg_forgejo_password }}" + db: forgejo diff --git a/k8s/apps-of-apps/apps/forgejo.yaml b/k8s/apps-of-apps/apps/forgejo.yaml new file mode 100644 index 0000000..13aedc4 --- /dev/null +++ b/k8s/apps-of-apps/apps/forgejo.yaml @@ -0,0 +1,24 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: forgejo + namespace: argocd + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: git@github.com:Alkatrazz24/Funk-lab.git + targetRevision: main + path: k8s/apps/forgejo + directory: + recurse: true + destination: + server: https://kubernetes.default.svc + namespace: ai + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/k8s/apps/forgejo/deployment.yaml b/k8s/apps/forgejo/deployment.yaml new file mode 100644 index 0000000..a0081b9 --- /dev/null +++ b/k8s/apps/forgejo/deployment.yaml @@ -0,0 +1,99 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forgejo + namespace: ai +spec: + replicas: 1 + strategy: + type: Recreate # PVC RWO : pas de deux pods qui montent /data en parallèle + selector: + matchLabels: + app: forgejo + template: + metadata: + labels: + app: forgejo + spec: + containers: + - name: forgejo + image: codeberg.org/forgejo/forgejo:11 + ports: + - containerPort: 3000 + name: http + env: + # --- Base PostgreSQL sur storage-01 (hors cluster), pattern Ghostfolio/n8n --- + - name: FORGEJO__database__DB_TYPE + value: "postgres" + - name: FORGEJO__database__HOST + value: "192.168.10.1:5432" + - name: FORGEJO__database__NAME + value: "forgejo" + - name: FORGEJO__database__USER + value: "forgejo" + - name: FORGEJO__database__PASSWD + valueFrom: + secretKeyRef: + name: forgejo-secret + key: pg-password + # --- Serveur : URL canonique = domaine HTTPS (split-horizon dnsmasq en LAN) --- + - name: FORGEJO__server__DOMAIN + value: "git.funklab.online" + - name: FORGEJO__server__ROOT_URL + value: "https://git.funklab.online/" + - name: FORGEJO__server__HTTP_PORT + value: "3000" + # Pas de git-over-SSH : miroir + consultation en HTTPS uniquement (aucun + # port 22 supplémentaire exposé). Le clone/pull passe par HTTPS. + - name: FORGEJO__server__DISABLE_SSH + value: "true" + # --- Service : inscription fermée → connexion via SSO Authentik uniquement --- + - name: FORGEJO__service__DISABLE_REGISTRATION + value: "true" + # Autorise la création de compte au 1er login OIDC (source externe) + - name: FORGEJO__service__ALLOW_ONLY_EXTERNAL_REGISTRATION + value: "true" + - name: FORGEJO__service__ENABLE_BASIC_AUTHENTICATION + value: "true" # clone HTTPS avec token perso + # --- Sécurité : install déjà verrouillée (config par env), clé stable --- + - name: FORGEJO__security__INSTALL_LOCK + value: "true" + - name: FORGEJO__security__SECRET_KEY + valueFrom: + secretKeyRef: + name: forgejo-secret + key: secret-key + - name: FORGEJO__migrations__ALLOWED_DOMAINS + value: "github.com" # miroir : ne tire que depuis GitHub + - name: USER_UID + value: "1000" + - name: USER_GID + value: "1000" + - name: TZ + value: "Europe/Paris" + volumeMounts: + - name: data + mountPath: /data + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + cpu: "1000m" + memory: 768Mi + readinessProbe: + httpGet: + path: /api/healthz + port: 3000 + initialDelaySeconds: 20 + periodSeconds: 15 + livenessProbe: + httpGet: + path: /api/healthz + port: 3000 + initialDelaySeconds: 60 + periodSeconds: 30 + volumes: + - name: data + persistentVolumeClaim: + claimName: forgejo-data diff --git a/k8s/apps/forgejo/ingress-public.yaml b/k8s/apps/forgejo/ingress-public.yaml new file mode 100644 index 0000000..4beb777 --- /dev/null +++ b/k8s/apps/forgejo/ingress-public.yaml @@ -0,0 +1,24 @@ +# Accès public HTTPS — git.funklab.online (cert Let's Encrypt auto). +# Hérite du durcissement edge : middlewares security-headers + ratelimit (ns infra). +# Route interne git.lab.local conservée (ingress.yaml). +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: forgejo-public + namespace: ai +spec: + entryPoints: + - websecure + routes: + - match: Host(`git.funklab.online`) + kind: Rule + middlewares: + - name: security-headers + namespace: infra + - name: ratelimit + namespace: infra + services: + - name: forgejo + port: 3000 + tls: + certResolver: letsencrypt diff --git a/k8s/apps/forgejo/ingress.yaml b/k8s/apps/forgejo/ingress.yaml new file mode 100644 index 0000000..9c14bd4 --- /dev/null +++ b/k8s/apps/forgejo/ingress.yaml @@ -0,0 +1,15 @@ +# Accès interne LAN — git.lab.local (HTTP, via dnsmasq wildcard → Traefik). +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: forgejo + namespace: ai +spec: + entryPoints: + - web + routes: + - match: Host(`git.lab.local`) + kind: Rule + services: + - name: forgejo + port: 3000 diff --git a/k8s/apps/forgejo/pvc.yaml b/k8s/apps/forgejo/pvc.yaml new file mode 100644 index 0000000..6613eda --- /dev/null +++ b/k8s/apps/forgejo/pvc.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: forgejo-data + namespace: ai +spec: + # /data : dépôts git (miroir de GitHub), avatars, LFS, app.ini (config générée + + # INTERNAL_TOKEN persistant). La base relationnelle est sur storage-01 (PostgreSQL), + # seul le contenu git vit ici. + accessModes: + - ReadWriteOnce + storageClassName: nfs + resources: + requests: + storage: 10Gi diff --git a/k8s/apps/forgejo/service.yaml b/k8s/apps/forgejo/service.yaml new file mode 100644 index 0000000..df39c46 --- /dev/null +++ b/k8s/apps/forgejo/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: forgejo + namespace: ai +spec: + selector: + app: forgejo + ports: + - port: 3000 + targetPort: 3000