feat(cozyplane): give tenants the cozyplane API through cozy:tenant

The cozyplane chart's tenant roles aggregate into the built-in
admin/edit/view ClusterRoles, which no Cozystack tenant is bound to, so
VPC self-service was Forbidden for every tenant. The wrapper carries
them across: one role aggregates the chart's edit role into cozy:tenant
(the tenant ServiceAccount Flux applies tenant releases as) and the
admin tier, another the view role into the view tier. Aggregating the
chart's roles instead of copying their rules keeps the list of tenant
kinds the chart's to maintain, the NAT gateways and route tables the
last re-vendor added included.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
This commit is contained in:
Timofei Larkin committed 2026-11-19 12:04:16 +01:00
1 parent 02914f60ec
commit 57bb0d703f
2 files changed
+92

No files matched your search

@@ -0,0 +1,31 @@
{{- /* Cozystack tenants hold the cozy:tenant* roles, not the built-in
admin/edit/view the cozyplane chart's own tenant roles aggregate into.
These roles carry those rules across by aggregating the chart's roles,
so the list of tenant kinds stays the chart's to maintain. */}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cozy:tenant:cozyplane-edit
labels:
rbac.cozystack.io/aggregate-to-tenant: "true"
rbac.cozystack.io/aggregate-to-tenant-admin: "true"
aggregationRule:
clusterRoleSelectors:
- matchLabels:
app.kubernetes.io/part-of: cozyplane
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rules: []
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cozy:tenant:cozyplane-view
labels:
rbac.cozystack.io/aggregate-to-tenant-view: "true"
aggregationRule:
clusterRoleSelectors:
- matchLabels:
app.kubernetes.io/part-of: cozyplane
rbac.authorization.k8s.io/aggregate-to-view: "true"
rules: []
@@ -0,0 +1,61 @@
suite: tenants get the cozyplane tenant API through the cozy:tenant tiers
# Cozystack tenants are bound only to cozy:tenant*, whose aggregation selects
# rbac.cozystack.io labels; the cozyplane chart's own tenant roles carry the
# built-in admin/edit/view labels, which no tenant holds.
templates:
- templates/tenant-rbac.yaml
- charts/cozyplane/templates/tenant-rbac.yaml
release:
name: cozyplane
namespace: cozy-cozyplane
tests:
# cozy:tenant is the tenant ServiceAccount's role (the identity Flux applies
# tenant releases as); admin is the human tier that manages VPCs.
- it: carries the chart's edit role into the tenant and admin tiers
template: templates/tenant-rbac.yaml
documentSelector:
path: metadata.name
value: cozy:tenant:cozyplane-edit
asserts:
- equal:
path: metadata.labels
value:
rbac.cozystack.io/aggregate-to-tenant: "true"
rbac.cozystack.io/aggregate-to-tenant-admin: "true"
- equal:
path: aggregationRule.clusterRoleSelectors
value:
- matchLabels:
app.kubernetes.io/part-of: cozyplane
rbac.authorization.k8s.io/aggregate-to-edit: "true"
- it: carries the chart's view role into the view tier
template: templates/tenant-rbac.yaml
documentSelector:
path: metadata.name
value: cozy:tenant:cozyplane-view
asserts:
- equal:
path: metadata.labels
value:
rbac.cozystack.io/aggregate-to-tenant-view: "true"
- equal:
path: aggregationRule.clusterRoleSelectors
value:
- matchLabels:
app.kubernetes.io/part-of: cozyplane
rbac.authorization.k8s.io/aggregate-to-view: "true"
# The selectors must match the chart's roles, or the aggregation is empty.
- it: matches the labels the chart's tenant roles actually carry
template: charts/cozyplane/templates/tenant-rbac.yaml
documentSelector:
path: metadata.name
value: cozyplane-tenant-edit
asserts:
- equal:
path: metadata.labels["app.kubernetes.io/part-of"]
value: cozyplane
- equal:
path: metadata.labels["rbac.authorization.k8s.io/aggregate-to-edit"]
value: "true"