Files
cozystack/packages/system/cozystack-controller/tests/rbac_test.yaml
T
Aleksei Sviridkin c841c70866 feat(operator): replicate operator wildcard certificate to tenant namespaces
The operator-provided wildcard MVP serves the root tenant only: the root
ingress controller and Gateway read a TLS Secret from their own namespace.
Child tenants run their own ingress controller / Gateway in a separate,
default-deny namespace and cannot read that Secret cross-namespace.

Add a controller that mirrors the operator wildcard Secret into every
tenant namespace that owns a TLS termination point (its
namespace.cozystack.io/ingress or .../gateway label equals its own name).
The source is identified by name from the platform values channel
(_cluster.wildcard-secret-name) with no extra operator input; replicas
carry a managed-by label and refresh on rotation. An individual replica is
removed when its namespace stops terminating TLS; every replica is torn
down only on an explicit disable (clearing wildcard-secret-name). A missing
or mistyped source, or a transiently-absent values channel, keeps existing
replicas, so tenant TLS never drops on a transient gap. The controller's
Secret cache is scoped to managed replicas and the values channel, not
every cluster Secret. Only the platform controller's ServiceAccount gains
Secret writes — no tenant RBAC is widened, and every consumer reads only
its own-namespace copy.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-07-01 10:47:14 +03:00

30 lines
1005 B
YAML

suite: cozystack-controller ClusterRole grants the wildcard-replication secrets write
templates:
- templates/rbac.yaml
release:
name: cozystack-controller
namespace: cozy-system
# The WildcardSecret reconciler replicates the operator wildcard TLS Secret
# into tenant namespaces, so the platform controller's ServiceAccount needs
# Secret write verbs (read was already covered by the catch-all rule). This
# rule gates the whole feature, so pin it. It scopes the platform
# controller's own SA only — it does not widen any tenant's RBAC.
tests:
- it: grants secrets get/list/watch/create/update/patch/delete on the ClusterRole
documentSelector:
path: kind
value: ClusterRole
asserts:
- equal:
path: metadata.name
value: cozystack-controller
- contains:
path: rules
content:
apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]