145 lines
4.1 KiB
Markdown
145 lines
4.1 KiB
Markdown
# Skill Sidecars i auto-RBAC
|
|
|
|
#sympozium #agenty #skills #rbac #security
|
|
|
|
## Koncepcja
|
|
|
|
Skill Sidecars to **najważniejsza innowacja bezpieczeństwa** Sympozium. Zamiast dawać agentowi bezpośredni dostęp do kubectl/helm/git, narzędzia uruchamiane są w **oddzielnym kontenerze z własnym, efemerycznym RBAC**.
|
|
|
|
## Dlaczego to ważne?
|
|
|
|
### Problem: In-process tool execution
|
|
W frameworkach jak kagent/LangChain, narzędzia działają w tym samym procesie co agent:
|
|
```
|
|
Agent (z credentials) → tool call → kubectl (z credentials agenta)
|
|
```
|
|
Jeśli LLM zostanie "przekonany" do złośliwego tool call, ma pełne uprawnienia procesu.
|
|
|
|
### Rozwiązanie: Sidecar isolation
|
|
```
|
|
Agent (BEZ credentials) → /ipc/tools/*.json → IPC Bridge → NATS
|
|
→ Skill Sidecar (z WŁASNYMI, scoped credentials) → kubectl
|
|
```
|
|
|
|
Agent **nigdy nie posiada** credentials do K8s API. Tylko sidecar je ma, i to z least-privilege RBAC.
|
|
|
|
## Mechanizm
|
|
|
|
### 1. Deklaracja RBAC w SkillPack
|
|
|
|
```yaml
|
|
# SkillPack CRD
|
|
spec:
|
|
sidecar:
|
|
rbac: # Namespace-scoped
|
|
- apiGroups: ["", "apps"]
|
|
resources: ["pods", "deployments"]
|
|
verbs: ["get", "list", "watch"]
|
|
clusterRBAC: # Cluster-scoped
|
|
- apiGroups: [""]
|
|
resources: ["nodes"]
|
|
verbs: ["get", "list"]
|
|
```
|
|
|
|
### 2. Auto-provisioning przy starcie AgentRun
|
|
|
|
```
|
|
AgentRun Pending:
|
|
↓
|
|
Controller czyta SkillPack RBAC declarations
|
|
↓
|
|
Tworzy:
|
|
├── ServiceAccount: sympozium-agent (w namespace runu)
|
|
├── Role: agentrun-<name>-<skill>
|
|
│ └── rules: [z SkillPack rbac]
|
|
├── RoleBinding: agentrun-<name>-<skill>
|
|
│ └── roleRef → Role, subject → ServiceAccount
|
|
├── ClusterRole: agentrun-<name>-<skill>
|
|
│ └── rules: [z SkillPack clusterRBAC]
|
|
└── ClusterRoleBinding: agentrun-<name>-<skill>
|
|
└── roleRef → ClusterRole, subject → ServiceAccount
|
|
```
|
|
|
|
### 3. Garbage collection po zakończeniu
|
|
|
|
```
|
|
AgentRun Succeeded/Failed:
|
|
↓
|
|
Namespace RBAC:
|
|
└── Automatyczne via ownerReference → AgentRun
|
|
(K8s GC czyści gdy AgentRun usunięty)
|
|
↓
|
|
Cluster RBAC:
|
|
└── Controller szuka po labelach:
|
|
sympozium.ai/agentrun: <name>
|
|
→ Delete ClusterRole
|
|
→ Delete ClusterRoleBinding
|
|
```
|
|
|
|
## Lifecycle RBAC
|
|
|
|
```
|
|
AgentRun created
|
|
↓
|
|
[RBAC created] ← credentials istnieją
|
|
↓
|
|
Agent pod running - sidecar używa credentials
|
|
↓
|
|
AgentRun completed
|
|
↓
|
|
[RBAC deleted] ← credentials nie istnieją
|
|
```
|
|
|
|
**Czas życia credentials = czas życia AgentRun** - to odpowiednik temporary IAM session credentials w AWS.
|
|
|
|
## Secret mirroring
|
|
|
|
Jeśli SkillPack referencjonuje Secret (np. GH_TOKEN):
|
|
```
|
|
Secret w sympozium-system → Kopia w namespace AgentRun
|
|
→ Montowany w sidecarze pod /secrets/<name>/
|
|
→ Usuwany po zakończeniu
|
|
```
|
|
|
|
## Parametryzacja
|
|
|
|
Ten sam SkillPack może być konfigurowany inaczej per instancja:
|
|
```yaml
|
|
# Instance A
|
|
skills:
|
|
- skillPackRef: github-gitops
|
|
params:
|
|
REPO: team-a/repo-a
|
|
|
|
# Instance B
|
|
skills:
|
|
- skillPackRef: github-gitops
|
|
params:
|
|
REPO: team-b/repo-b
|
|
```
|
|
|
|
Params → env vars `SKILL_REPO` w sidecarze.
|
|
|
|
## Architektura bezpieczeństwa
|
|
|
|
```
|
|
┌─────────────────────────────────┐
|
|
│ Agent Pod │
|
|
│ │
|
|
│ ┌──────────┐ ┌──────────────┐ │
|
|
│ │ Agent │ │ Skill Sidecar│ │
|
|
│ │ │ │ │ │
|
|
│ │ BEZ K8s │ │ Z RBAC: │ │
|
|
│ │ credentials│ │ - Role │ │
|
|
│ │ │ │ - Binding │ │
|
|
│ │ /ipc → │ │ - SA token │ │
|
|
│ └──────────┘ └──────────────┘ │
|
|
│ │ ↑ │
|
|
│ └──── IPC ─────┘ │
|
|
└─────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
Powiązane: [[Efemeryczny RBAC per-run]] | [[SkillPack]] | [[Model bezpieczeństwa Defence-in-Depth]]
|