From 3a1bb156b9aee455b7699202ffc68644be2323e4 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Tue, 3 Nov 2026 05:25:02 +0300 Subject: [PATCH] feat(cozystack-basics): let every authenticated user read GPUClass The GPU catalog is what a tenant picks a class from, from a portal or from kubectl and GitOps without one, so every authenticated user reads it. GPUClass is cluster-scoped and tenant roles are bound per namespace, so the read goes through its own ClusterRole bound to system:authenticated. Nothing grants a write: classes are the hoster's. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- .../templates/clusterroles.yaml | 24 ++++++++++ .../tests/clusterroles-gpuclass_test.yaml | 47 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 packages/system/cozystack-basics/tests/clusterroles-gpuclass_test.yaml diff --git a/packages/system/cozystack-basics/templates/clusterroles.yaml b/packages/system/cozystack-basics/templates/clusterroles.yaml index 1c7ecb688..49cc5b775 100644 --- a/packages/system/cozystack-basics/templates/clusterroles.yaml +++ b/packages/system/cozystack-basics/templates/clusterroles.yaml @@ -382,3 +382,27 @@ rules: - '*' verbs: - '*' +--- +# GPUClass is the hoster's catalog and is cluster-scoped, so tenant roles, +# bound per namespace, cannot grant its read. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: cozy:gpuclasses:view +rules: +- apiGroups: ["cozystack.io"] + resources: ["gpuclasses"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: cozy:gpuclasses:view:authenticated +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cozy:gpuclasses:view +subjects: +- apiGroup: rbac.authorization.k8s.io + kind: Group + name: system:authenticated diff --git a/packages/system/cozystack-basics/tests/clusterroles-gpuclass_test.yaml b/packages/system/cozystack-basics/tests/clusterroles-gpuclass_test.yaml new file mode 100644 index 000000000..ae3f072e1 --- /dev/null +++ b/packages/system/cozystack-basics/tests/clusterroles-gpuclass_test.yaml @@ -0,0 +1,47 @@ +suite: cozystack-basics GPUClass catalog read + +templates: + - templates/clusterroles.yaml + +release: + name: cozystack-basics + namespace: cozy-system + +# GPUClass is the hoster's catalog: every authenticated user reads it, from +# a portal or from kubectl, and nobody but the hoster writes it. It is +# cluster-scoped, so tenant roles, which are bound per namespace, could not +# grant it even if they named it. +tests: + - it: renders a read-only GPUClass role + documentSelector: + path: metadata.name + value: cozy:gpuclasses:view + asserts: + - isKind: + of: ClusterRole + - equal: + path: rules + value: + - apiGroups: ["cozystack.io"] + resources: ["gpuclasses"] + verbs: ["get", "list", "watch"] + + - it: binds the GPUClass role to every authenticated user + documentSelector: + path: metadata.name + value: cozy:gpuclasses:view:authenticated + asserts: + - isKind: + of: ClusterRoleBinding + - equal: + path: roleRef + value: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cozy:gpuclasses:view + - equal: + path: subjects + value: + - apiGroup: rbac.authorization.k8s.io + kind: Group + name: system:authenticated