mirror of
https://github.com/Alkatrazz24/Funk-lab.git
synced 2026-07-08 05:34:43 +02:00
Permet de configurer des alertes « préviens-moi par mail quand NVDA atteint 200$ » depuis la Console IA. Un sidecar surveille les cours en continu. - finlab/watcher.py : boucle toutes les 5 min, lit price_alerts.yaml (workspace), évalue les seuils above/below, envoie un email au franchissement. Anti-spam (1 mail/seuil, état .watcher-state.json, ré-armé en ré-éditant). Modes --once / --test - Email via le relais postfix du lab (storage-01:25, SMTP_HOST) qui réécrit l'expéditeur en Gmail — AUCUN secret (pods k8s dans mynetworks) - price_alerts.yaml : config seedée dans le workspace (email_to + rules), éditée par la Console IA sur demande - deployment : conteneur sidecar `watcher` (boucle 5 min, ressources minimes) - Dockerfile : seed price_alerts.yaml ; persona console + admin/ia/finlab.md documentés Logique testée en local (SMTP mocké) : franchissement → envoi, anti-spam au 2e run, seuil non atteint → rien. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
124 lines
4.5 KiB
YAML
124 lines
4.5 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: finlab
|
|
namespace: ai
|
|
spec:
|
|
replicas: 1
|
|
# HOME + workspace sur un volume RWO (NFS) → pas de rolling à 2 pods sur le même volume.
|
|
strategy:
|
|
type: Recreate
|
|
selector:
|
|
matchLabels:
|
|
app: finlab
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: finlab
|
|
spec:
|
|
imagePullSecrets:
|
|
- name: ghcr-pull
|
|
# PodSecurity « restricted » (ns ai). fsGroup 1000 → PVC NFS monté en /home/finlab.
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 1000
|
|
runAsGroup: 1000
|
|
fsGroup: 1000
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
# initContainer : prépare le workspace (seed robuste NFS) AVANT console + dashboard,
|
|
# pour qu'il soit peuplé et inscriptible quand les deux conteneurs démarrent.
|
|
initContainers:
|
|
- name: seed
|
|
image: ghcr.io/alkatrazz24/funk-finlab:sha-73e2ad3
|
|
command: ["/usr/local/bin/entrypoint-seed.sh"]
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
volumeMounts:
|
|
- name: home
|
|
mountPath: /home/finlab
|
|
containers:
|
|
# ── CONSOLE : Claude Code dans un terminal web (ttyd), sous /console ──
|
|
- name: console
|
|
image: ghcr.io/alkatrazz24/funk-finlab:sha-73e2ad3
|
|
command: ["/usr/local/bin/entrypoint-console.sh"]
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
ports:
|
|
- name: console
|
|
containerPort: 7681
|
|
readinessProbe:
|
|
tcpSocket: { port: 7681 }
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 15
|
|
livenessProbe:
|
|
tcpSocket: { port: 7681 }
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 30
|
|
# Claude Code est bursty : CPU moy. ~0,2 cœur mais throttlé ~11 % en pic à 1 cœur
|
|
# (mesuré). On double le plafond CPU pour des bursts plus fluides. La RAM n'était pas
|
|
# contrainte (~384 Mo) ; un peu de marge par confort. (La latence du modèle, elle,
|
|
# reste côté API — non impactée par les ressources du pod.)
|
|
resources:
|
|
requests: { cpu: 300m, memory: 768Mi }
|
|
limits: { cpu: "2", memory: 2Gi }
|
|
volumeMounts:
|
|
- name: home
|
|
mountPath: /home/finlab
|
|
# ── DASHBOARD : interface web (FastAPI), graphiques + données finlab ──
|
|
- name: dashboard
|
|
image: ghcr.io/alkatrazz24/funk-finlab:sha-73e2ad3
|
|
command:
|
|
- /opt/venv/bin/uvicorn
|
|
- dashboard.server:app
|
|
- --host=0.0.0.0
|
|
- --port=8800
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
ports:
|
|
- name: web
|
|
containerPort: 8800
|
|
# FINLAB_HOME/PYTHONPATH viennent de l'image ; FINLAB_HOME = workspace (configs live).
|
|
readinessProbe:
|
|
httpGet: { path: /healthz, port: 8800 }
|
|
initialDelaySeconds: 8
|
|
periodSeconds: 15
|
|
livenessProbe:
|
|
httpGet: { path: /healthz, port: 8800 }
|
|
initialDelaySeconds: 20
|
|
periodSeconds: 30
|
|
resources:
|
|
requests: { cpu: 100m, memory: 256Mi }
|
|
limits: { cpu: 500m, memory: 768Mi }
|
|
volumeMounts:
|
|
- name: home
|
|
mountPath: /home/finlab
|
|
# ── WATCHER : alertes de prix par email (boucle 5 min → relais postfix storage-01) ──
|
|
- name: watcher
|
|
image: ghcr.io/alkatrazz24/funk-finlab:sha-73e2ad3
|
|
command: ["/opt/venv/bin/python", "-m", "finlab.watcher"]
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
env:
|
|
# Relais SMTP du lab (storage-01) — accepte les pods k8s (mynetworks), pas de secret.
|
|
- { name: SMTP_HOST, value: "192.168.10.1" }
|
|
- { name: SMTP_PORT, value: "25" }
|
|
- { name: WATCH_INTERVAL, value: "300" }
|
|
resources:
|
|
requests: { cpu: 25m, memory: 192Mi }
|
|
limits: { cpu: 250m, memory: 384Mi }
|
|
volumeMounts:
|
|
- name: home
|
|
mountPath: /home/finlab
|
|
volumes:
|
|
- name: home
|
|
persistentVolumeClaim:
|
|
claimName: finlab-data
|