From dcbdebe96b2c3e1fb85910d234fc2aa1a250fd33 Mon Sep 17 00:00:00 2001 From: mrbobbytables Date: Sat, 19 Sep 2026 21:06:13 +0000 Subject: [PATCH 1/2] fix(kiosk): grant cluster read and metrics RBAC to kubestellar-console Add dedicated ServiceAccount, ClusterRole, and ClusterRoleBinding allowing kubestellar-console to query nodes, namespaces, pods, services, events, configmaps, workload controllers, metrics.k8s.io, and tenancy.kflex.kubestellar.org controlplanes out of the box so the console hydrates live cluster state instead of defaulting to demo cards. Fixes #193 Assisted-by: github-copilot/gemini-3.8-flash via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: mrbobbytables --- .../kubestellar/40-kubestellar-console.yaml | 38 +++++++++++++++++++ tests/unit/test_kubestellar_kiosk.py | 10 +++++ 2 files changed, 48 insertions(+) diff --git a/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml b/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml index fc502bdf..54333921 100644 --- a/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml +++ b/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml @@ -4,6 +4,43 @@ metadata: name: kubestellar-console --- apiVersion: v1 +kind: ServiceAccount +metadata: + name: kubestellar-console + namespace: kubestellar-console +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: kubestellar-console +rules: +- apiGroups: [""] + resources: ["nodes", "namespaces", "pods", "services", "events", "configmaps"] + verbs: ["get", "list", "watch"] +- apiGroups: ["apps"] + resources: ["deployments", "statefulsets", "daemonsets", "replicasets"] + verbs: ["get", "list", "watch"] +- apiGroups: ["metrics.k8s.io"] + resources: ["nodes", "pods"] + verbs: ["get", "list"] +- apiGroups: ["tenancy.kflex.kubestellar.org"] + resources: ["controlplanes"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: kubestellar-console +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kubestellar-console +subjects: +- kind: ServiceAccount + name: kubestellar-console + namespace: kubestellar-console +--- +apiVersion: v1 kind: Service metadata: name: kubestellar-console @@ -38,6 +75,7 @@ spec: labels: app.kubernetes.io/name: kubestellar-console spec: + serviceAccountName: kubestellar-console containers: - name: console image: ghcr.io/kubestellar/console:v0.3.34 diff --git a/tests/unit/test_kubestellar_kiosk.py b/tests/unit/test_kubestellar_kiosk.py index ec608c72..c74cd89a 100644 --- a/tests/unit/test_kubestellar_kiosk.py +++ b/tests/unit/test_kubestellar_kiosk.py @@ -83,6 +83,16 @@ def test_gate_waits_for_session_and_blocks_until_agent_health() -> None: def test_console_provides_local_and_oauth_login_options() -> None: console = CONSOLE_MANIFEST.read_text(encoding="utf-8") + assert "kind: ServiceAccount" in console + assert "kind: ClusterRole" in console + assert "kind: ClusterRoleBinding" in console + assert "serviceAccountName: kubestellar-console" in console + assert ( + 'resources: ["nodes", "namespaces", "pods", "services", "events", "configmaps"]' + in console + ) + assert 'apiGroups: ["metrics.k8s.io"]' in console + assert 'apiGroups: ["tenancy.kflex.kubestellar.org"]' in console assert "name: DEV_MODE" in console assert 'value: "true"' in console assert "name: ALLOW_DEV_MODE_IN_CLUSTER" in console From 6d33d2c32900e3b0d8597f2ec3eec4ebdd041848 Mon Sep 17 00:00:00 2001 From: mrbobbytables Date: Sun, 20 Sep 2026 01:58:23 +0000 Subject: [PATCH 2/2] fix(kiosk): drop configmaps from console ClusterRole and separate RBAC test Drop cluster-wide configmaps read access from kubestellar-console ClusterRole to prevent unauthenticated/dev-mode exposure of sensitive configuration in kiosk environments. Move the RBAC assertions into a dedicated unit test test_console_has_cluster_read_rbac. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: mrbobbytables --- .../kubestellar/40-kubestellar-console.yaml | 2 +- tests/unit/test_kubestellar_kiosk.py | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml b/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml index 54333921..acc46bd8 100644 --- a/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml +++ b/files/k0s/manifests/kubestellar/40-kubestellar-console.yaml @@ -15,7 +15,7 @@ metadata: name: kubestellar-console rules: - apiGroups: [""] - resources: ["nodes", "namespaces", "pods", "services", "events", "configmaps"] + resources: ["nodes", "namespaces", "pods", "services", "events"] verbs: ["get", "list", "watch"] - apiGroups: ["apps"] resources: ["deployments", "statefulsets", "daemonsets", "replicasets"] diff --git a/tests/unit/test_kubestellar_kiosk.py b/tests/unit/test_kubestellar_kiosk.py index c74cd89a..9f67adb1 100644 --- a/tests/unit/test_kubestellar_kiosk.py +++ b/tests/unit/test_kubestellar_kiosk.py @@ -83,16 +83,6 @@ def test_gate_waits_for_session_and_blocks_until_agent_health() -> None: def test_console_provides_local_and_oauth_login_options() -> None: console = CONSOLE_MANIFEST.read_text(encoding="utf-8") - assert "kind: ServiceAccount" in console - assert "kind: ClusterRole" in console - assert "kind: ClusterRoleBinding" in console - assert "serviceAccountName: kubestellar-console" in console - assert ( - 'resources: ["nodes", "namespaces", "pods", "services", "events", "configmaps"]' - in console - ) - assert 'apiGroups: ["metrics.k8s.io"]' in console - assert 'apiGroups: ["tenancy.kflex.kubestellar.org"]' in console assert "name: DEV_MODE" in console assert 'value: "true"' in console assert "name: ALLOW_DEV_MODE_IN_CLUSTER" in console @@ -105,6 +95,21 @@ def test_console_provides_local_and_oauth_login_options() -> None: assert "optional: true" in console +def test_console_has_cluster_read_rbac() -> None: + console = CONSOLE_MANIFEST.read_text(encoding="utf-8") + + assert "kind: ServiceAccount" in console + assert "kind: ClusterRole" in console + assert "kind: ClusterRoleBinding" in console + assert "serviceAccountName: kubestellar-console" in console + assert ( + 'resources: ["nodes", "namespaces", "pods", "services", "events"]' + in console + ) + assert 'apiGroups: ["metrics.k8s.io"]' in console + assert 'apiGroups: ["tenancy.kflex.kubestellar.org"]' in console + + def test_proxy_is_the_only_public_console_endpoint() -> None: proxy = PROXY_MANIFEST.read_text(encoding="utf-8")