Funk-lab/k8s/apps/finlab/README.md
ALI YESILKAYA 54f6f7c634
feat(finlab): console Claude Code finance in-cluster + toolkit d'analyse (#64)
* feat(finlab): console Claude Code finance in-cluster + toolkit d'analyse

Intègre finlab (ex-projet Projets/Finance) au lab comme une console Claude Code
web spécialisée finance — l'esprit OpenAlice, mais c'est le vrai Claude Code sur
l'abonnement (login persisté, pas d'API facturée), agentique, avec la boîte à
outils finlab (Yahoo Finance) branchée en MCP.

- tools/finlab/ : source finlab rapatriée + Dockerfile (Python 3.12 + Node +
  claude-code + ttyd) + persona workspace/CLAUDE.md + branchement MCP + entrypoint
  (seed du workspace no-clobber sur le PVC)
- .github/workflows/build-finlab.yml : build GHCR funk-finlab + bump manifest (main)
- k8s/apps/finlab/ : Deployment/Service/PVC/IngressRoute (finance.lab.local) +
  Middleware basicAuth (shell web protégé) ; PVC = HOME (login) + workspace
- k8s/apps-of-apps/apps/finlab.yaml : Application ArgoCD
- .mcp.json (racine) : outils finlab dans les sessions Claude Code du lab
- admin/ia/finlab.md + READMEs + CLAUDE.md : doc + enregistrement

Analyse/aide à la décision uniquement — aucun ordre réel (paper trading Alpaca
fictif seul exécutable).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(finlab): ttyd absent des dépôts bookworm → binaire statique GitHub

Le build amont échouait (`E: Package 'ttyd' has no installation candidate`) :
ttyd n'est pas packagé dans Debian bookworm. On récupère le binaire statique
(musl, pin TTYD_VERSION=1.7.7) depuis les releases GitHub. Build complet validé
en local (podman) : ttyd 1.7.7, claude-code 2.1.195, import finlab + seed OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 23:26:09 +02:00

68 lines
3 KiB
Markdown

# FinLab — console Claude Code finance (in-cluster)
Une **vraie session Claude Code** (sur l'**abonnement** d'Alkatrazz, login persisté) servie
dans un **terminal web** (`ttyd`), spécialisée analyse de marché via la persona `CLAUDE.md` et
la boîte à outils **finlab** (Yahoo Finance, exposée en **MCP**). Esprit OpenAlice, mais c'est
Claude Code + le toolkit maison — **aucune facturation API**, **aucun broker**, analyse seule.
> ⚠️ La console expose un **shell web** → protégée par **basicAuth Traefik**. Analyse et aide à
> la décision uniquement : **aucun ordre réel** (seul le paper trading Alpaca fictif existe).
## Image
Pas d'image publique : la CI (`.github/workflows/build-finlab.yml`) build depuis
`tools/finlab/` (notre code) → `ghcr.io/alkatrazz24/funk-finlab`, tag `sha-<court>`, bump du
manifest sur `main`.
## Architecture du déploiement
| Composant | Détail |
|---|---|
| Deployment | 1 réplica, `Recreate` (volume RWO), PodSecurity *restricted* (uid 1000, `fsGroup` 1000) |
| PVC `finlab-data` | 5Gi NFS → `/home/finlab` : `~/.claude` (login abonnement) + workspace (code finlab seedé, `portfolio.yaml`/`watchlists.yaml`/`alerts.yaml` éditables, `.cache`) |
| Service `finlab` | `web:7681` (ttyd) |
| Middleware `finlab-auth` | basicAuth Traefik (secret `finlab-auth`, htpasswd) |
| IngressRoute | `finance.lab.local` → 7681 (via `finlab-auth`) |
Le workspace est **seedé depuis l'image au 1er boot** (`cp -rn`, no-clobber) puis vit sur le
PVC : tes edits (portefeuille, etc.) et ton login persistent ; une nouvelle image n'apporte que
les fichiers manquants.
## Pré-requis manuels (une fois)
### 1. Secret de pull GHCR (si absent du ns `ai`)
```bash
kubectl -n ai create secret docker-registry ghcr-pull \
--docker-server=ghcr.io \
--docker-username=Alkatrazz24 \
--docker-password=<GHCR_PAT_read_packages>
```
### 2. Secret basicAuth de la console (`finlab-auth`)
```bash
# htpasswd (paquet apache2-utils). Remplace <user>/<pass>.
htpasswd -nbB <user> '<pass>' > /tmp/finlab.htpasswd
kubectl -n ai create secret generic finlab-auth \
--from-file=users=/tmp/finlab.htpasswd
rm -f /tmp/finlab.htpasswd
```
### 3. Premier boot — login Claude Code (abonnement)
1. Ouvrir **http://finance.lab.local** (basicAuth → identifiants de l'étape 2).
2. Dans le terminal, lancer `claude`, puis `/login` → suivre l'OAuth (ouvrir l'URL sur ta
machine, autoriser, coller le code). Persisté dans `~/.claude` sur le PVC.
3. À l'invite, FinLab a déjà sa persona (`CLAUDE.md`) et les outils finlab (MCP `finlab`,
auto-activé). Essaie : *« résume mon portefeuille »*, *« plan de trade pour Micron »*.
> Le workspace `/home/finlab/workspace` contient `portfolio.yaml` etc. — éditables directement
> (par toi ou par Claude à ta demande). Pour une vue rapide hors console :
> `kubectl -n ai exec deploy/finlab -- python -m finlab.cli digest`.
## Accès depuis le terminal (sans navigateur)
```bash
kubectl -n ai exec -it deploy/finlab -- bash -lc 'cd "$WORKSPACE" && claude'
```