initial commit
This commit is contained in:
104
02-Architektura/Orchestrator - PodBuilder i Spawner.md
Normal file
104
02-Architektura/Orchestrator - PodBuilder i Spawner.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Orchestrator - PodBuilder i Spawner
|
||||
|
||||
#sympozium #architektura #orchestrator
|
||||
|
||||
## Lokalizacja
|
||||
|
||||
`internal/orchestrator/` - pakiet odpowiedzialny za budowanie specyfikacji podów i spawning Job'ów.
|
||||
|
||||
## PodBuilder
|
||||
|
||||
`PodBuilder` to struct odpowiedzialny za konstruowanie pod spec'ów. Konfigurowany jest tagiem obrazów:
|
||||
|
||||
```go
|
||||
type PodBuilder struct {
|
||||
DefaultAgentImage string // agent-runner
|
||||
DefaultIPCBridgeImage string // ipc-bridge
|
||||
DefaultSandboxImage string // sandbox
|
||||
DefaultMCPBridgeImage string // mcp-bridge
|
||||
EventBusURL string // nats://nats.sympozium-system.svc:4222
|
||||
ImageTag string // np. "v0.0.25"
|
||||
}
|
||||
```
|
||||
|
||||
Registry: `ghcr.io/sympozium-ai/sympozium`
|
||||
|
||||
## Budowanie kontenerów
|
||||
|
||||
### BuildAgentContainer
|
||||
Główny kontener agenta z:
|
||||
- Read-only root filesystem
|
||||
- Drop ALL capabilities
|
||||
- No privilege escalation
|
||||
- Woluminy: workspace, skills (ro), ipc, tmp
|
||||
- EnvFrom: secret z kluczem API
|
||||
|
||||
### BuildIPCBridgeContainer
|
||||
Sidecar IPC bridge z:
|
||||
- Wolumin ipc (shared z agentem)
|
||||
- Env: AGENT_RUN_ID, INSTANCE_NAME, EVENT_BUS_URL
|
||||
- Opcjonalnie: TRACEPARENT, OTEL_* (observability)
|
||||
|
||||
### BuildSandboxContainer
|
||||
Opcjonalny sidecar sandbox z:
|
||||
- Read-only root filesystem
|
||||
- Drop ALL capabilities
|
||||
- Command: `sleep infinity` (czeka na komendy z agenta)
|
||||
- Woluminy: workspace, tmp
|
||||
|
||||
### BuildVolumes
|
||||
4 woluminy:
|
||||
- `workspace` - emptyDir 1Gi
|
||||
- `ipc` - emptyDir (Memory medium) 64Mi - **RAM-backed** dla szybkości
|
||||
- `tmp` - emptyDir 256Mi
|
||||
- `skills` - Projected volume z ConfigMapów SkillPacks
|
||||
|
||||
## AgentPodConfig
|
||||
|
||||
Konfiguracja przekazywana do buildera:
|
||||
|
||||
```go
|
||||
type AgentPodConfig struct {
|
||||
RunID string
|
||||
InstanceName string
|
||||
AgentID string
|
||||
SessionKey string
|
||||
ModelProvider string
|
||||
ModelName string
|
||||
ThinkingMode string
|
||||
AuthSecretRef string
|
||||
SandboxEnabled bool
|
||||
SandboxImage string
|
||||
SpawnDepth int
|
||||
Skills []SkillMount
|
||||
Traceparent string // W3C traceparent
|
||||
OTelEndpoint string // OTLP endpoint
|
||||
}
|
||||
```
|
||||
|
||||
## Proces tworzenia poda (w AgentRunReconciler)
|
||||
|
||||
```
|
||||
1. reconcilePending()
|
||||
├── validatePolicy() - sprawdza SympoziumPolicy
|
||||
├── ensureAgentServiceAccount() - ServiceAccount w namespace
|
||||
├── createInputConfigMap() - task + system prompt
|
||||
├── resolveSkillSidecars() - SkillPack CRDs → sidecar specs
|
||||
├── ensureMCPConfigMap() - konfiguracja MCP serwerów
|
||||
├── buildContainers() - PodBuilder buduje spec
|
||||
├── createEphemeralRBAC() - Role + RoleBinding per sidecar
|
||||
└── createJob() / createSandboxCR() - finalne tworzenie zasobu K8s
|
||||
```
|
||||
|
||||
## Relacja z AgentRun Controller
|
||||
|
||||
`AgentRunReconciler` (`internal/controller/agentrun_controller.go`) jest "klientem" PodBuilder'a. Reconciler:
|
||||
1. Obserwuje AgentRun CRDs
|
||||
2. Używa PodBuilder do budowania spec'ów
|
||||
3. Tworzy Job/Sandbox CR w Kubernetes
|
||||
4. Monitoruje lifecycle poda
|
||||
5. Zbiera wyniki i czyści zasoby
|
||||
|
||||
---
|
||||
|
||||
Powiązane: [[Cykl życia Agent Pod]] | [[AgentRun]] | [[Cykl życia AgentRun]]
|
||||
Reference in New Issue
Block a user