[ready-to-test] k3s: expand agent read access without secrets (#1)

## Summary

Expand the `agent-gateway/agent-readonly` service account from the built-in `view` role to a dedicated read-only role.

## Access policy

- Adds `get`, `list`, and `watch` for the core cluster resources and all currently served non-core API groups.
- Adds read-only non-resource access for API discovery, health, OpenAPI, and version endpoints.
- Does not grant access to the Kubernetes `secrets` resource.
- Does not grant write verbs, exec, port-forward, proxy, or token creation permissions.

## Verification

- Current target `org1/k3s:main`: `2bbac8467a9297e7056956328f576978142f3b24`
- `git diff --check`: passed
- Changed file: `k3s_rencher/infrastructure/agent-gateway/rbac.yaml`

The existing binding name is preserved so Flux applies the role change in place.

## Kustomize inclusion

The root `k3s_rencher/kustomization.yaml` already includes `infrastructure/agent-gateway`. Its nested Kustomization includes `rbac.yaml`, so the new ClusterRole is applied transitively while preserving the `agent-gateway` namespace transformation. A duplicate direct root entry would cause duplicate resource processing.

---------

Co-authored-by: admin <rudolfss13@gmail.com>
Reviewed-on: org1/k3s#1
Co-authored-by: Alex Rudenk <rudolfss13+hermes@gmail.com>
This commit was merged in pull request #1.
This commit is contained in:
2026-11-11 13:02:40 +01:00
committed by admin
co-authored by admin
parent a355d51a22
commit fc6f668a86
@@ -5,14 +5,108 @@ metadata:
namespace: agent-gateway
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: agent-readonly-all-except-secrets
rules:
- apiGroups:
- ""
resources:
- bindings
- componentstatuses
- configmaps
- endpoints
- events
- limitranges
- namespaces
- namespaces/status
- nodes
- nodes/status
- persistentvolumeclaims
- persistentvolumeclaims/status
- persistentvolumes
- persistentvolumes/status
- pods
- pods/ephemeralcontainers
- pods/log
- pods/status
- podtemplates
- replicationcontrollers
- replicationcontrollers/status
- resourcequotas
- resourcequotas/status
- serviceaccounts
- services
- services/status
verbs:
- get
- list
- watch
- apiGroups:
- apiregistration.k8s.io
- apps
- admissionregistration.k8s.io
- apiextensions.k8s.io
- authentication.k8s.io
- authorization.k8s.io
- autoscaling
- batch
- certificates.k8s.io
- coordination.k8s.io
- discovery.k8s.io
- events.k8s.io
- flowcontrol.apiserver.k8s.io
- gateway.networking.k8s.io
- helm.cattle.io
- helm.toolkit.fluxcd.io
- hub.traefik.io
- image.toolkit.fluxcd.io
- k3s.cattle.io
- kustomize.toolkit.fluxcd.io
- metrics.k8s.io
- networking.k8s.io
- node.k8s.io
- notification.toolkit.fluxcd.io
- policy
- rbac.authorization.k8s.io
- resource.k8s.io
- scheduling.k8s.io
- source.toolkit.fluxcd.io
- storage.k8s.io
- traefik.io
resources:
- "*"
verbs:
- get
- list
- watch
- nonResourceURLs:
- /api
- /api/*
- /apis
- /apis/*
- /healthz
- /healthz/*
- /livez
- /livez/*
- /openapi
- /openapi/*
- /readyz
- /readyz/*
- /version
- /version/*
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: agent-readonly-view
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
name: agent-readonly-all-except-secrets
subjects:
- kind: ServiceAccount
name: agent-readonly
namespace: agent-gateway
namespace: agent-gateway