Skip to content

Commit 9ed5483

Browse files
authored
feat(computeplane): provision a ComputePlane tenant module for untrusted-code apps (#3280)
## What this PR does Implements the ComputePlane per the merged design proposal ([cozystack/community design-proposals/compute-plane](https://github.com/cozystack/community/tree/main/design-proposals/compute-plane); supersedes the earlier #3150 which was built on the pre-revision surface and came from a fork): a managed, isolated environment for running code-executing (untrusted-code) catalog applications. ComputePlane is delivered as an operator-owned **tenant module**: - **`packages/extra/computeplane`** — the module chart. Provisions a single-tenant, Cozystack-managed cluster by deploying the ordinary `apps/kubernetes` chart (Kamaji control plane + KubeVirt-VM workers) with operator-fixed values: the Cozystack-enablement addons (`fluxcd` + pinned distribution artifact, `certManager`, `ingressNginx` with `exposeMethod: Proxied`) are inline `spec.values`, so nothing injected via `valuesFrom` can disable them. The tenant can set cluster *shape* (`nodeGroups`, schema-validated) and receives no admin kubeconfig. - **Release naming**: neither HelmRelease sets `spec.releaseName` — the aggregated API rebuilds HelmRelease specs without that field, so both releases derive names from their object names. The cluster HelmRelease object is `computeplane-cluster`, and Kamaji writes the admin kubeconfig to the derived Secret **`computeplane-cluster-admin-kubeconfig`** — the contract future `placement: ComputePlane` routing consumes. Tenant-visible secrets are an allowlist (`include: []` withholds everything), so the credential is withheld by construction. - **`packages/system/computeplane-rd`** — registers the `ComputePlane` module-kind (`ApplicationDefinition`, `dashboard.module: true`). - **`packages/core/platform/sources/computeplane-application.yaml`** — self-contained package source: re-declares `apps/kubernetes` as its own source-only component; `dependsOn` cozystack-engine (ApplicationDefinition CRD) and kubernetes-application (registration ordering). Ships in the `iaas` bundle (variant `kubevirt`). - **Tenant toggle** — `computeplane: false` bool. The tenant chart fails loudly when the module is toggled on without the iaas package. Note: automatic `placement: ComputePlane` routing is a deferred follow-up and is not part of this PR; until it lands, external catalogs target the cluster via its kubeconfig Secret. - **`apps/kubernetes` fix** — the Proxied ingress `Service` renders only when the ingress-nginx addon is enabled **and** the tenant has etcd (mirroring the addon HelmRelease gates), independent of the `hosts` list. Follow-ups tracked separately: `placement` routing in cozystack-api, scoped per-service egress, visibility/mutation access control, e2e (#3369), release-name guards for the remaining extra charts (#3371). Tests: helm-unittest suites pin the module contract (object names, no explicit releaseName, tamper-proof inline addons, nodeGroups validation + ingress-role guard, unlisted-field pass-through), the tenant toggle, the package-source/bundle wiring, and the ingress Service gates. ### Screenshots Not a UI change. ### Release note ```release-note feat(computeplane): ComputePlane tenant module — a single-tenant, Cozystack-managed cluster for untrusted-code applications, delivered as an operator-owned extra module wrapping the kubernetes app. Enable with `computeplane: true` on the Tenant; the tenant receives no admin kubeconfig for it, and the cluster's admin kubeconfig Secret is `computeplane-cluster-admin-kubeconfig`. Catalog routing (`placement: ComputePlane`) ships separately. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a new **ComputePlane** tenant option (`computeplane`, default off) to provision an isolated single-tenant environment for untrusted-code applications, including cluster creation and configurable **node groups**. * **Bug Fixes** * Refined ingress-nginx proxied rendering rules to avoid emitting incomplete resources: Ingress/Services are now gated on addon enablement (and etcd-backed tenancy), with correct behavior when hosts aren’t provided. * **Documentation / Tests** * Updated tenant and ComputePlane documentation; added/extended rendering tests for the new ComputePlane module and ingress-nginx gating (including release-name and etcd-less cases). <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents e6460db + 93338cc commit 9ed5483

28 files changed

Lines changed: 932 additions & 3 deletions

File tree

‎api/apps/v1alpha1/tenant/types.go‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/apps/kubernetes/templates/ingress.yaml‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{{- $ingress := .Values._namespace.ingress }}
2-
{{- if and (eq .Values.addons.ingressNginx.exposeMethod "Proxied") .Values.addons.ingressNginx.hosts }}
2+
{{- /* The _namespace.etcd gate mirrors the ingress-nginx addon HelmRelease:
3+
on an etcd-less tenant the chart collapses to the awaiting-etcd beacon,
4+
so no addon controller exists and the Service would select nothing. */}}
5+
{{- if and .Values.addons.ingressNginx.enabled .Values._namespace.etcd (eq .Values.addons.ingressNginx.exposeMethod "Proxied") }}
6+
{{- if .Values.addons.ingressNginx.hosts }}
37
---
48
apiVersion: networking.k8s.io/v1
59
kind: Ingress
@@ -41,7 +45,18 @@ spec:
4145
port:
4246
number: 80
4347
{{- end }}
48+
{{- end }}
4449
---
50+
# The proxy Service is created whenever the addon is enabled on an etcd-backed
51+
# tenant with exposeMethod Proxied (independent of `hosts`) so that external
52+
# consumers — e.g. a ComputePlane app's per-app management Ingress — can route to
53+
# the tenant cluster's ingress-nginx without the tenant module having to know
54+
# every app host in advance. Both gates match the addon HelmRelease this Service
55+
# fronts: exposeMethod defaults to Proxied while the addon defaults to off, so
56+
# gating on exposeMethod alone would emit a selector-less Service on every cluster
57+
# that runs no ingress-nginx at all; and on an etcd-less tenant the chart collapses
58+
# to the awaiting-etcd beacon, so the Service would select a controller that never
59+
# renders.
4560
apiVersion: v1
4661
kind: Service
4762
metadata:
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
suite: proxied ingress Service gates on the addon, not on hosts
2+
# exposeMethod defaults to Proxied while addons.ingressNginx.enabled defaults
3+
# to false, so the Service must render only when the addon is actually on —
4+
# otherwise every cluster without ingress-nginx grows a Service whose selector
5+
# (node-role.kubernetes.io/ingress-nginx) matches no pods, and kubernetes-rd
6+
# surfaces it in the tenant dashboard advertising ports that route nowhere.
7+
# The Service intentionally does NOT require `hosts`: a ComputePlane app's
8+
# per-app management Ingress routes to it without the module knowing app hosts
9+
# in advance.
10+
templates:
11+
- templates/ingress.yaml
12+
release:
13+
name: kubernetes-alice
14+
namespace: tenant-alice
15+
set:
16+
_namespace:
17+
ingress: tenant-root
18+
etcd: tenant-root
19+
tests:
20+
- it: renders nothing when the addon is disabled (default)
21+
asserts:
22+
- hasDocuments:
23+
count: 0
24+
25+
- it: renders the Service (and no Ingress) when enabled with Proxied and no hosts
26+
set:
27+
addons:
28+
ingressNginx:
29+
enabled: true
30+
exposeMethod: Proxied
31+
hosts: []
32+
asserts:
33+
- hasDocuments:
34+
count: 1
35+
- isKind:
36+
of: Service
37+
- equal:
38+
path: metadata.name
39+
value: kubernetes-alice-ingress-nginx
40+
41+
- it: renders Ingress and Service when enabled with Proxied and hosts
42+
set:
43+
addons:
44+
ingressNginx:
45+
enabled: true
46+
exposeMethod: Proxied
47+
hosts: ["app.example.com"]
48+
asserts:
49+
- hasDocuments:
50+
count: 2
51+
52+
# Deliberate behaviour change pinned: hosts with the addon disabled used to
53+
# render the Ingress; "the addon is off" now means nothing renders at all.
54+
- it: renders nothing when hosts are set but the addon is disabled
55+
set:
56+
addons:
57+
ingressNginx:
58+
enabled: false
59+
exposeMethod: Proxied
60+
hosts: ["app.example.com"]
61+
asserts:
62+
- hasDocuments:
63+
count: 0
64+
65+
# The addon HelmRelease itself gates on _namespace.etcd (the etcd-less
66+
# render collapses to the awaiting-etcd beacon), so the Service must too —
67+
# otherwise an etcd-less tenant with the addon pinned on (ComputePlane)
68+
# gets the selector-less Service by another route.
69+
- it: renders nothing on an etcd-less tenant even with the addon enabled
70+
set:
71+
_namespace:
72+
ingress: tenant-root
73+
etcd: ""
74+
addons:
75+
ingressNginx:
76+
enabled: true
77+
exposeMethod: Proxied
78+
hosts: []
79+
asserts:
80+
- hasDocuments:
81+
count: 0

‎packages/apps/tenant/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ tenant-u1
8282
| `ingress` | Deploy own Ingress Controller. | `bool` | `false` |
8383
| `gateway` | Deploy own Gateway API Gateway (backed by Cilium Gateway API controller). When unset (the default), the chart auto-enables the Gateway for tenants whose apex is derived from the parent (i.e. `host` is empty), and leaves it off for tenants with a custom non-derived apex. Set to `true` or `false` explicitly to override that auto-behaviour. Note: leave the key absent (do not write `gateway: null`) — the chart distinguishes "unset" via missing-key, not via null value, to satisfy the JSON schema generated from this comment. | `bool` | `false` |
8484
| `seaweedfs` | Deploy own SeaweedFS. | `bool` | `false` |
85+
| `computeplane` | Deploy own ComputePlane — a single-tenant, Cozystack-managed cluster for untrusted-code applications. The tenant receives no admin kubeconfig for it. Automatic routing of catalog applications onto it (placement: ComputePlane) is a planned follow-up and is not available yet; until it lands, external catalogs target the cluster via its computeplane-cluster-admin-kubeconfig Secret. See design-proposals/compute-plane in cozystack/community. | `bool` | `false` |
8586
| `schedulingClass` | The name of a SchedulingClass CR to apply scheduling constraints for this tenant's workloads. | `string` | `""` |
8687
| `resourceQuotas` | Define resource quotas for the tenant. | `map[string]quantity` | `{}` |
8788

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{- /*
2+
ComputePlane tenant module.
3+
4+
When enabled, deploys the operator-owned computeplane module chart
5+
(packages/extra/computeplane), which in turn provisions a single-tenant,
6+
Cozystack-managed cluster for untrusted-code workloads by deploying the
7+
ordinary `kubernetes` app with operator-fixed values. The tenant gets no
8+
admin kubeconfig for that cluster; see design-proposals/compute-plane in
9+
cozystack/community.
10+
*/}}
11+
{{- if .Values.computeplane }}
12+
{{- /*
13+
Fail loudly when the module is toggled on without its backing package: the
14+
computeplane-application package ships in the iaas bundle while this toggle
15+
arrives with tenant-rd in the system bundle, and bundles are independent
16+
booleans. Without this guard a system+paas install would render a
17+
HelmRelease pointing at a nonexistent ExternalArtifact and retry forever
18+
with no diagnostic. The Capabilities gate keeps the check active in-cluster
19+
(the Package CRD is always installed there) while letting offline renders
20+
(helm template / helm-unittest, where lookup returns nothing) pass. Note
21+
the guard deliberately fails closed on a nil lookup once the API group is
22+
discoverable: a client-side `helm template --validate` against a live
23+
cluster would trip it, but no packaging path in this repo renders the
24+
tenant chart that way — Flux renders in-cluster where lookup works.
25+
*/}}
26+
{{- if .Capabilities.APIVersions.Has "cozystack.io/v1alpha1" }}
27+
{{- if not (lookup "cozystack.io/v1alpha1" "Package" "" "cozystack.computeplane-application") }}
28+
{{- fail "computeplane module is enabled, but the cozystack.computeplane-application package is not installed — it ships in the iaas bundle (set bundles.iaas.enabled: true)" }}
29+
{{- end }}
30+
{{- end }}
31+
apiVersion: helm.toolkit.fluxcd.io/v2
32+
kind: HelmRelease
33+
metadata:
34+
name: computeplane
35+
namespace: {{ include "tenant.name" . }}
36+
labels:
37+
sharding.fluxcd.io/key: tenants
38+
internal.cozystack.io/tenantmodule: "true"
39+
app.kubernetes.io/instance: {{ .Release.Name }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
apps.cozystack.io/application.kind: ComputePlane
42+
apps.cozystack.io/application.group: apps.cozystack.io
43+
apps.cozystack.io/application.name: computeplane
44+
spec:
45+
# No spec.releaseName — the aggregated API rebuilds HelmRelease specs
46+
# without it, so the release name must equal the object name (as in every
47+
# other tenant module). The cluster HelmRelease this module renders is the
48+
# separately-named computeplane-cluster, whose derived release name makes
49+
# Kamaji write the admin kubeconfig to computeplane-cluster-admin-kubeconfig
50+
# (see packages/extra/computeplane/templates/cluster.yaml).
51+
chartRef:
52+
kind: ExternalArtifact
53+
name: cozystack-computeplane-application-kubevirt-computeplane
54+
namespace: cozy-system
55+
interval: 5m
56+
timeout: 10m
57+
install:
58+
remediation:
59+
retries: -1
60+
upgrade:
61+
remediation:
62+
retries: -1
63+
valuesFrom:
64+
- kind: Secret
65+
name: cozystack-values
66+
{{- end }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
suite: tenant computeplane module toggle
2+
# The computeplane module provisions a single-tenant, Cozystack-managed
3+
# cluster for untrusted-code apps (design-proposals/compute-plane in
4+
# cozystack/community). Contract pinned here:
5+
# - off by default — no HelmRelease;
6+
# - NO spec.releaseName on the module HelmRelease: the aggregated API
7+
# rebuilds HelmRelease specs without releaseName, so the release name
8+
# must always be the object name or the first tenant edit through the
9+
# API would rename the release out from under Helm.
10+
templates:
11+
- templates/computeplane.yaml
12+
release:
13+
name: tenant-alice
14+
namespace: tenant-alice
15+
tests:
16+
- it: renders nothing by default
17+
asserts:
18+
- hasDocuments:
19+
count: 0
20+
21+
- it: renders the module HelmRelease when enabled
22+
set:
23+
computeplane: true
24+
asserts:
25+
- hasDocuments:
26+
count: 1
27+
- equal:
28+
path: metadata.name
29+
value: computeplane
30+
- notExists:
31+
path: spec.releaseName
32+
- equal:
33+
path: spec.chartRef.name
34+
value: cozystack-computeplane-application-kubevirt-computeplane
35+
- equal:
36+
path: metadata.labels["internal.cozystack.io/tenantmodule"]
37+
value: "true"
38+
- equal:
39+
path: metadata.labels["apps.cozystack.io/application.kind"]
40+
value: ComputePlane

‎packages/apps/tenant/values.schema.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
"type": "boolean",
3232
"default": false
3333
},
34+
"computeplane": {
35+
"description": "Deploy own ComputePlane — a single-tenant, Cozystack-managed cluster for untrusted-code applications. The tenant receives no admin kubeconfig for it. Automatic routing of catalog applications onto it (placement: ComputePlane) is a planned follow-up and is not available yet; until it lands, external catalogs target the cluster via its computeplane-cluster-admin-kubeconfig Secret. See design-proposals/compute-plane in cozystack/community.",
36+
"type": "boolean",
37+
"default": false
38+
},
3439
"schedulingClass": {
3540
"description": "The name of a SchedulingClass CR to apply scheduling constraints for this tenant's workloads.",
3641
"type": "string",

‎packages/apps/tenant/values.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ ingress: false
1919
## @param {bool} seaweedfs - Deploy own SeaweedFS.
2020
seaweedfs: false
2121

22+
## @param {bool} computeplane - Deploy own ComputePlane — a single-tenant, Cozystack-managed cluster for untrusted-code applications. The tenant receives no admin kubeconfig for it. Automatic routing of catalog applications onto it (placement: ComputePlane) is a planned follow-up and is not available yet; until it lands, external catalogs target the cluster via its computeplane-cluster-admin-kubeconfig Secret. See design-proposals/compute-plane in cozystack/community.
23+
computeplane: false
24+
2225
## @param {string} [schedulingClass] - The name of a SchedulingClass CR to apply scheduling constraints for this tenant's workloads.
2326
schedulingClass: ""
2427

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
apiVersion: cozystack.io/v1alpha1
3+
kind: PackageSource
4+
metadata:
5+
name: cozystack.computeplane-application
6+
spec:
7+
sourceRef:
8+
kind: OCIRepository
9+
name: cozystack-packages
10+
namespace: cozy-system
11+
path: /
12+
variants:
13+
# The variant mirrors the kubernetes-application variant whose chart it
14+
# re-sources: the wrapped cluster substrate is the kubevirt flavour of
15+
# apps/kubernetes, and the artifact naming contract
16+
# (cozystack-computeplane-application-kubevirt-*) carries that provenance.
17+
# A future non-kubevirt substrate would arrive as a sibling variant.
18+
- name: kubevirt
19+
# Variant dependsOn gates only the components that carry an install:
20+
# block — here computeplane-rd alone. cozystack-engine serves the
21+
# ApplicationDefinition CRD that computeplane-rd installs; the
22+
# kubernetes-application edge orders that install after the kubernetes
23+
# machinery (CAPI providers, Kamaji, the addon artifacts) is present, so
24+
# the ComputePlane kind is not registered — and cannot be instantiated —
25+
# on a cluster that lacks what it provisions.
26+
dependsOn:
27+
- cozystack.cozystack-engine
28+
- cozystack.kubernetes-application
29+
libraries:
30+
- name: cozy-lib
31+
path: library/cozy-lib
32+
components:
33+
# The ComputePlane module chart (tenant module, source-only): rendered
34+
# into the tenant namespace by the tenant chart when the module is on.
35+
- name: computeplane
36+
path: extra/computeplane
37+
# The ordinary managed-kubernetes app, re-declared source-only under
38+
# this package's own scope (cozystack-computeplane-application-kubevirt-kubernetes)
39+
# so the module is self-contained and does not reach into another
40+
# package's artifacts for the cluster chart itself.
41+
- name: kubernetes
42+
path: apps/kubernetes
43+
libraries: ["cozy-lib"]
44+
- name: computeplane-rd
45+
path: system/computeplane-rd
46+
install:
47+
namespace: cozy-system
48+
releaseName: computeplane-rd

‎packages/core/platform/templates/bundles/iaas.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
{{include "cozystack.platform.package.default" (list "cozystack.bucket-application" $) }}
159159
{{include "cozystack.platform.package" (list "cozystack.kubernetes-application" "kubevirt" $) }}
160160
{{include "cozystack.platform.package" (list "cozystack.kubernetes-nodes-application" "kubevirt" $) }}
161+
{{include "cozystack.platform.package" (list "cozystack.computeplane-application" "kubevirt" $) }}
161162
{{include "cozystack.platform.package" (list "cozystack.virtualprivatecloud-application" "kubevirt" $) }}
162163
{{include "cozystack.platform.package" (list "cozystack.vm-disk-application" "kubevirt" $) }}
163164
{{include "cozystack.platform.package" (list "cozystack.vm-instance-application" "kubevirt" $) }}

0 commit comments

Comments
 (0)