Files
aiworker/QUICK-REFERENCE.md
Hector Ros f619c4bf56 Update QUICK-REFERENCE with current system state
- Add app.fuq.tv, api.fuq.tv, claude.fuq.tv URLs
- Add all 3 repos (frontend, backend, agent)
- Add API endpoints documentation (auth, projects, tasks, agents, mcp)
- Add testing section with curl examples
- Update project structure (frontend, agents now exist)
- Add rollout restart commands
- Update quick start session commands

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-01-20 16:47:17 +01:00

519 lines
11 KiB
Markdown

# ⚡ Quick Reference - Comandos y URLs
Referencia rápida de todo lo importante en un solo lugar.
---
## 🌐 URLs
| Servicio | URL | Credenciales | Estado |
|----------|-----|--------------|--------|
| **Frontend** | https://app.fuq.tv | - | ✅ Running (2 pods) |
| **Backend API** | https://api.fuq.tv | - | ✅ Running (2 pods) |
| **Terminal Web** | https://claude.fuq.tv | - | ✅ Running (tmux persistente) |
| **Gitea** | https://git.fuq.tv | admin / admin123 | ✅ Running |
| **ArgoCD** | https://argocd.fuq.tv | admin / LyPF4Hy0wvp52IoU | ✅ Running |
| **Longhorn** | https://longhorn.fuq.tv | admin / aiworker2026 | ✅ Running |
| **HAProxy Stats** | http://108.165.47.221:8404/stats | admin / aiworker2026 | ✅ Running |
### Repositorios Git
| Repo | URL | Descripción |
|------|-----|-------------|
| Frontend | https://git.fuq.tv/admin/aiworker-frontend | React + Vite + Tailwind |
| Backend | https://git.fuq.tv/admin/aiworker-backend | Bun + Drizzle + MCP |
| Agent | https://git.fuq.tv/admin/aiworker-agent | Ubuntu 24.04 + Claude Code |
| Actions (frontend) | https://git.fuq.tv/admin/aiworker-frontend/actions | CI/CD |
| Actions (backend) | https://git.fuq.tv/admin/aiworker-backend/actions | CI/CD |
| Actions (agent) | https://git.fuq.tv/admin/aiworker-agent/actions | CI/CD |
| Packages | https://git.fuq.tv/admin/-/packages | Container Registry |
---
## 🔑 Tokens y Secrets
```bash
# Gitea Full Access
159a5de2a16d15f33e388b55b1276e431dbca3f3
# Gitea Registry
7401126cfb56ab2aebba17755bdc968c20768c27
# K3s Token
K10e74a5aacfaf4e2e0a291c3b369db8588cf0b9c2590a4d66e04ab960e24fcb4db::server:bc53704a9707d3cd9188af9e558ab50c
```
---
## 💾 Base de Datos
### MariaDB (Interno)
```bash
Host: mariadb.control-plane.svc.cluster.local
Port: 3306
User: aiworker
Pass: AiWorker2026_UserPass!
DB: aiworker
```
### Conexión desde pod
```bash
kubectl exec -n control-plane mariadb-0 -- \
mariadb -uaiworker -pAiWorker2026_UserPass! aiworker
```
### Bases de datos
- `aiworker` - App principal
- `gitea` - Gitea data
---
## ☸️ Kubernetes
### Kubeconfig
```bash
export KUBECONFIG=~/.kube/aiworker-config
```
### Comandos Básicos
```bash
# Nodos
kubectl get nodes
# Todos los pods
kubectl get pods -A
# Pods en namespace
kubectl get pods -n control-plane
# Logs
kubectl logs -f <pod> -n <namespace>
# Exec
kubectl exec -it <pod> -n <namespace> -- /bin/sh
# Port-forward
kubectl port-forward svc/<service> 3000:3000 -n <namespace>
```
### Namespaces Principales
- `control-plane` - Backend, DB, Redis
- `agents` - Claude agents
- `gitea` - Git server
- `gitea-actions` - CI/CD runner
- `ingress-nginx` - Ingress
- `cert-manager` - TLS
- `longhorn-system` - Storage
- `argocd` - GitOps
---
## 🐳 Container Registry
### Login
```bash
docker login git.fuq.tv -u admin -p 7401126cfb56ab2aebba17755bdc968c20768c27
```
### Push
```bash
docker build -t git.fuq.tv/admin/<app>:<tag> .
docker push git.fuq.tv/admin/<app>:<tag>
```
### K8s Secret
```bash
kubectl create secret docker-registry gitea-registry \
--docker-server=git.fuq.tv \
--docker-username=admin \
--docker-password=7401126cfb56ab2aebba17755bdc968c20768c27 \
-n <namespace>
```
---
## 🖥️ SSH a Servidores
```bash
# Control Planes
ssh root@108.165.47.233 # k8s-cp-01
ssh root@108.165.47.235 # k8s-cp-02
ssh root@108.165.47.215 # k8s-cp-03
# Workers
ssh root@108.165.47.225 # k8s-worker-01
ssh root@108.165.47.224 # k8s-worker-02
ssh root@108.165.47.222 # k8s-worker-03
# Load Balancers
ssh root@108.165.47.221 # k8s-lb-01
ssh root@108.165.47.203 # k8s-lb-02
```
---
## 📦 Backend Development
### Local
```bash
cd backend
# Install deps
bun install
# Dev mode
bun run dev
# Generate migrations
bun run db:generate
# Build
bun build src/index.ts --outdir dist
```
### Port-forwards para desarrollo local
```bash
# Terminal 1: MariaDB
kubectl port-forward -n control-plane svc/mariadb 3306:3306
# Terminal 2: Redis
kubectl port-forward -n control-plane svc/redis 6379:6379
# Terminal 3: Backend
cd backend && bun run dev
```
---
## 🔄 Git Workflow
### Commits
```bash
git add .
git commit -m "Description
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>"
git push
```
### Ver Actions
```bash
open https://git.fuq.tv/admin/aiworker-backend/actions
```
### Build manual (si Actions falla)
```bash
# En un worker node
ssh root@108.165.47.225
cd /tmp
git clone https://git.fuq.tv/admin/aiworker-backend.git
cd aiworker-backend
docker build -t git.fuq.tv/admin/aiworker-backend:latest .
docker login git.fuq.tv -u admin -p 7401126cfb56ab2aebba17755bdc968c20768c27
docker push git.fuq.tv/admin/aiworker-backend:latest
```
---
## 🚀 Deploy
### Aplicar manifests
```bash
kubectl apply -f k8s/backend/
kubectl apply -f k8s/frontend/
```
### Ver estado
```bash
kubectl get all -n control-plane
kubectl logs -f deployment/backend -n control-plane
```
### Rollout
```bash
# Update image
kubectl set image deployment/backend backend=git.fuq.tv/admin/aiworker-backend:v2.0.0 -n control-plane
# Restart
kubectl rollout restart deployment/backend -n control-plane
# Status
kubectl rollout status deployment/backend -n control-plane
# Rollback
kubectl rollout undo deployment/backend -n control-plane
```
---
## 📊 Monitoring
### Resources
```bash
kubectl top nodes
kubectl top pods -A
kubectl top pods -n control-plane
```
### Logs
```bash
# Tail logs
kubectl logs -f <pod> -n <namespace>
# Logs recientes
kubectl logs --tail=100 <pod> -n <namespace>
# Logs de todos los containers
kubectl logs <pod> -n <namespace> --all-containers
```
### Events
```bash
kubectl get events -A --sort-by='.lastTimestamp' | tail -20
kubectl get events -n <namespace>
```
---
## 🗄️ Database
### Query rápido
```bash
kubectl exec -n control-plane mariadb-0 -- \
mariadb -uaiworker -pAiWorker2026_UserPass! aiworker \
-e "SHOW TABLES;"
```
### Backup
```bash
kubectl exec -n control-plane mariadb-0 -- \
mariadb-dump -uaiworker -pAiWorker2026_UserPass! aiworker \
> backup-$(date +%Y%m%d).sql
```
### Restore
```bash
cat backup.sql | kubectl exec -i -n control-plane mariadb-0 -- \
mariadb -uaiworker -pAiWorker2026_UserPass! aiworker
```
---
## 🔐 Secrets Management
### Create secret
```bash
kubectl create secret generic my-secret -n <namespace> \
--from-literal=key1=value1 \
--from-literal=key2=value2
```
### View secret
```bash
kubectl get secret my-secret -n <namespace> -o yaml
kubectl get secret my-secret -n <namespace> -o jsonpath='{.data.key1}' | base64 -d
```
---
## 🛠️ CubePath CLI
### Ver servidores
```bash
cubecli vps list
cubecli project list
```
### SSH a servidor
```bash
cubecli vps list | grep k8s-
ssh root@<ip>
```
---
## 🌍 DNS
**Configurado**:
```
*.fuq.tv → 108.165.47.221, 108.165.47.203
*.r.fuq.tv → 108.165.47.221, 108.165.47.203
```
**Verificar**:
```bash
dig api.fuq.tv +short
dig test.fuq.tv +short
```
---
## 🔌 API Endpoints
### Backend API (https://api.fuq.tv)
```bash
# Health
GET /api/health
# Auth
POST /api/auth/register
POST /api/auth/login
POST /api/auth/logout
GET /api/auth/me
# Projects (CRUD)
GET /api/projects
GET /api/projects/:id
POST /api/projects
PATCH /api/projects/:id
DELETE /api/projects/:id
# Tasks (CRUD)
GET /api/tasks
GET /api/tasks/:id
POST /api/tasks
PATCH /api/tasks/:id
DELETE /api/tasks/:id
# Agents (CRUD)
GET /api/agents
GET /api/agents/:id
POST /api/agents
PATCH /api/agents/:id
DELETE /api/agents/:id
# MCP Tools (para agentes)
GET /api/mcp/tools
POST /api/mcp/get_next_task
POST /api/mcp/update_task_status
POST /api/mcp/create_branch
POST /api/mcp/create_pull_request
POST /api/mcp/ask_user_question
```
---
## 📁 ESTRUCTURA DEL PROYECTO
```
teamSquadAiWorker/
├── backend/ # Bun backend (✅ Desplegado)
│ ├── src/
│ │ ├── api/routes/ # Auth, Projects, Tasks, Agents, MCP
│ │ ├── db/ # Drizzle schema + migrations
│ │ └── index.ts # Bun.serve()
│ ├── Dockerfile
│ └── .gitea/workflows/
├── frontend/ # React + Vite (✅ Desplegado)
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Login, Register, Dashboard
│ │ ├── api/ # API client
│ │ └── lib/ # Auth context
│ ├── Dockerfile
│ └── .gitea/workflows/
├── agents/ # Claude Code agent (✅ Desplegado)
│ ├── Dockerfile # Ubuntu 24.04 + Node 24 + Bun
│ ├── mcp-bridge-server.js
│ ├── claude-code-config.json
│ └── AGENT-ACCESS.md
├── k8s/ # Kubernetes manifests (✅ Aplicados)
│ ├── backend/ # Deployment, Service, Ingress
│ ├── frontend/ # Deployment, Service, Ingress
│ └── agents/ # Deployment, ServiceAccount
├── docs/ # Documentación completa
├── past-sessions/ # Sesiones anteriores
│ ├── 2026-01-19-infrastructure-deployment.md
│ ├── 2026-01-19-backend-api-implementation.md
│ └── 2026-01-20-frontend-mcp-agents.md
├── ROADMAP.md # Plan general
├── NEXT-SESSION.md # Próximos pasos detallados
├── TROUBLESHOOTING.md # Solución de problemas
├── QUICK-REFERENCE.md # Este archivo
├── K8S-CLUSTER.md # Estado del cluster
└── CLUSTER-CREDENTIALS.md # Credenciales (sensible)
```
---
## 🎯 INICIO RÁPIDO DE SESIÓN
```bash
# 1. Verificar cluster
export KUBECONFIG=~/.kube/aiworker-config
kubectl get nodes
# 2. Ver servicios
kubectl get pods -n control-plane # frontend, backend
kubectl get pods -n agents # claude-agent, claude-terminal
kubectl get pods -n gitea # gitea
# 3. Verificar URLs funcionan
curl -s https://app.fuq.tv/ | grep "AiWorker"
curl -s https://api.fuq.tv/api/health | jq .
curl -s https://claude.fuq.tv/ | head -5
# 4. Desarrollo local
cd backend && bun run dev # Backend
cd frontend && bun run dev # Frontend
# 5. Ver CI/CD builds
open https://git.fuq.tv/admin/aiworker-frontend/actions
open https://git.fuq.tv/admin/aiworker-backend/actions
open https://git.fuq.tv/admin/aiworker-agent/actions
# 6. Rollout restart después de builds
kubectl rollout restart deployment/frontend -n control-plane
kubectl rollout restart deployment/backend -n control-plane
kubectl rollout restart deployment/claude-agent -n agents
# 7. Continuar donde te quedaste
cat NEXT-SESSION.md
```
---
## 🧪 Testing Rápido
### Frontend
```bash
# Login y crear proyecto
open https://app.fuq.tv
# Register → Login → New Project → Click Project → New Task
```
### Backend API
```bash
# Health check
curl -s https://api.fuq.tv/api/health | jq .
# Register user
curl -X POST https://api.fuq.tv/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","username":"test","password":"test1234"}'
# List projects
curl -s https://api.fuq.tv/api/projects | jq .
# MCP tools
curl -s https://api.fuq.tv/api/mcp/tools | jq '.tools[] | .name'
```
### Agent
```bash
# Conectar al terminal web
open https://claude.fuq.tv
# O conectar al pod directamente
kubectl exec -it -n agents deployment/claude-agent -- /bin/bash
cd /workspace
claude
```
---
## 🎊 FIN DE QUICK REFERENCE
**Todo lo importante en un solo lugar. ¡Guarda este archivo!**