# RBAC - Role-Based Access Control #kubernetes #security #rbac #słownik ## Co to jest? **RBAC** (Role-Based Access Control) to system autoryzacji w Kubernetes. Definiuje **kto** (subject) może wykonywać **jakie operacje** (verbs) na **jakich zasobach** (resources). ## Komponenty ### Role (namespace-scoped) ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: pod-reader namespace: my-namespace rules: - apiGroups: [""] # "" = core API group resources: ["pods"] verbs: ["get", "list", "watch"] ``` ### ClusterRole (cluster-scoped) ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: node-reader rules: - apiGroups: [""] resources: ["nodes"] verbs: ["get", "list"] ``` ### RoleBinding (wiąże Role z podmiotem) ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: read-pods subjects: - kind: ServiceAccount name: my-agent roleRef: kind: Role name: pod-reader apiGroup: rbac.authorization.k8s.io ``` ## Verbs | Verb | Opis | |------|------| | `get` | Odczyt pojedynczego zasobu | | `list` | Listowanie zasobów | | `watch` | Obserwowanie zmian (streaming) | | `create` | Tworzenie nowego zasobu | | `update` | Aktualizacja istniejącego | | `patch` | Częściowa aktualizacja | | `delete` | Usuwanie zasobu | ## Scope | Typ | Scope | Binding | |-----|-------|---------| | **Role** | Namespace | RoleBinding | | **ClusterRole** | Cały klaster | ClusterRoleBinding | | **ClusterRole** | Namespace (reuse) | RoleBinding | ## Privilege escalation prevention Kubernetes nie pozwala na tworzenie ról z uprawnieniami większymi niż posiada twórca. Dlatego controller Sympozium wymaga `cluster-admin` - musi tworzyć dowolne role zdefiniowane w [[SkillPack|SkillPacks]]. ## Użycie w Sympozium Sympozium implementuje **efemeryczny RBAC per-run**: 1. [[SkillPack]] deklaruje potrzebne uprawnienia (rbac/clusterRBAC) 2. Przy tworzeniu [[AgentRun]], controller tworzy: - Role + RoleBinding (namespace-scoped, [[ownerReference]] → AgentRun) - ClusterRole + ClusterRoleBinding (label-based cleanup) 3. Po zakończeniu runu → RBAC usunięty Credentials istnieją **tylko przez czas trwania runu**. Więcej: [[Efemeryczny RBAC per-run]] | [[Skill Sidecars i auto-RBAC]] --- Powiązane: [[Efemeryczny RBAC per-run]] | [[ServiceAccount]] | [[Skill Sidecars i auto-RBAC]]