Commit Graph
7 Commits
Author SHA1 Message Date
Aleksei Sviridkin 7554abf715 feat(api): add the GPUClass catalog to cozystack.io
GPU offers need stable names for tenant budgets and billing while the
host layer can change its device-plugin resource names. Publish the
offer metadata and a UID-scoped acknowledgement of the underlying resource name,
separate from readiness and from GPU capacity.

Keep immutable offer details on the class, require a profile for vGPU,
and retain the CRD on chart uninstall. The shipped-schema tests exercise
create, update and status preparation through the apiserver strategies,
including malformed fields and status isolation.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-28 07:07:54 +03:00
Timofei Larkin 9f00135618 feat(api): add EndpointAttachment to attach addresses to app endpoints
A managed application's tenant-facing Services are its endpoints, and
the only way to publish one externally has been the chart boolean
`external`, which publishes one chart-chosen endpoint on one address
from no particular pool through five different render paths.
EndpointAttachment attaches one address, minted from an IPAddressClass
or bound from a reserved IPAddressClaim, to one tenant-facing Service by
rendering an additive LoadBalancer Service that mirrors the endpoint's
selector and ports. The mechanism therefore needs no per-engine render
knowledge and never touches the application's own objects, and a
reserved address survives every attachment and moves between
applications. The Service carries the loadBalancerClass the claim's
class reports in status, so it reaches the load balancer that owns the
class's pool; since a Service's loadBalancerClass is immutable, nothing
new is rendered before the class's provisioner accepts the class for its
current generation. The rendered Service asks for the claim's IP
families, since one left to the cluster's primary family cannot be
assigned an address of the other.

The endpoint check requires both the lineage labels and the
tenantresource marker: lineage alone also covers operator-internal
Services. A LoadBalancer Service a tenant Kubernetes cluster's
cloud-controller-manager creates carries the cluster's labels and the
marker too, so the cluster.x-k8s.io/tenant-service-name label it writes
excludes it. Identity is by owner reference throughout, so a Service
carrying the ownership label without the reference is never adopted,
and a same-name recreated application does not inherit the previous
incarnation's attachments.

The VM datapath modes render the cozy-proxy Service contract unchanged
and are gated on a platform declaration rather than CNI detection: a
proxy skips a Service delegated to a name it does not claim while the
load balancer still attracts the address. Exclusivity is keyed on the
backend pod in both modes because cozy-proxy's egress map holds one
address per pod, and holds IPv4 only, so a method attachment off a VPC
refuses an IPv6 or Dual claim. A delegation no attachment renders, such
as a chart Service with external: true, always takes the pod, since
nothing would ever withdraw it; between attachments the oldest wins. A
whole-IP attachment with several ready backends keeps its address dark
instead of picking one.

A cozyplane VPC changes that for whole-IP: the VM's only interface is
in the VPC, so the launcher pod address a cozy-proxy Service maps to
never reaches it. Where a backend pod carries the VM chart's
sdn.cozystack.io/vpc annotation and the cluster serves cozyplane's
FloatingIP, the attachment owns a FloatingIP on the VM's VPC address
wearing its claim instead, and mirrors its readiness once its status
is for its current generation: a re-pointed FloatingIP keeps the old
target's status until cozyplane observes the change. FloatingIP is
read as unstructured and used only when served, so the controller
keeps no dependency on cozyplane. A live migration's two launcher pods
share the VM's VPC address and count as one target, and a stopped VM
keeps its binding rather than flipping to a cozy-proxy Service. Only
a backend pod says whether a VM is in a VPC, so a method attachment
that has published nothing yet waits for one; otherwise an attachment
created before its VM starts would pin the claim to a cozy-proxy
Service first.
PortList is refused there: a FloatingIP binds every port and cozy-proxy
cannot reach the VPC address. So is a Dual claim, since a FloatingIP
wears one address. The kube-ovn VPC keeps the pod-network
interface and adds VPC subnets as secondary interfaces, so the
cozy-proxy path still delivers to the VM there.

The e2e suite is the only one that needs the address substrate, so it
owns both of its optional packages in test selection: the e2e install
enables them, a selection that leaves the suite out disables them, and
post-install prep gives the sandbox a default IPAddressClass on a pool
MetalLB does not auto-assign from. The cozyplane VPC suite stays
parked, because no e2e lane installs that networking variant.

The kind lives in local.sdn.cozystack.io, the CRD-served half of the
sdn family the address substrate and cozyplane share, so stock
ResourceQuota counts keep working.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-27 08:33:56 +01:00
Aleksei Sviridkin 9f72f0bda9 feat(api): refuse a WorkloadMonitor with an empty selector
An empty selector matches every Pod, PVC, Service and DataVolume in the
namespace, so one such monitor goes non-operational on any import there.
No chart renders one, but the schema marked the field required without
requiring any label, and the API accepted it.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-10-02 14:02:37 +03:00
Nikita Aboltin 8732dc96cf feat(api): add configurable resources and replicas for cozystack-engine components
- cozystack-api, cozystack-controller, lineage-controller-webhook: conditional
  resources block via `{{- with .Values.*.resources }}`, defaulting to `{}` so the
  default render stays unchanged
- cozystack-controller: replicas comes from values (was hardcoded 1); the chart
  now passes --leader-elect unconditionally and grants the Lease verbs through a
  namespaced Role and RoleBinding in cozy-system (the Lease lives in the manager's
  own namespace), so raising replicas adds a standby instead of a second active
  writer over the reconcilers that patch HelmReleases, Gateways, Certificates,
  ResourceQuotas and Secrets

Signed-off-by: Nikita Aboltin <aboltin.nikita@rwb.ru>
2026-09-28 15:19:45 +03:00
Aleksei Sviridkin 62204d4903 test(cozystack-controller): guard the Secret grant by effective permission
The suite's "does not grant a blanket wildcard verb on secrets" assert
was a notContains over a rule object. helm-unittest compares every field
it is handed by value equality, and `any: true` changes which fields are
compared rather than how, so no spelling of that assert bounds what a
verbs list may hold: `verbs: ["get", "*"]` satisfies all of them.

Measured against the rendered ClusterRole, seven realistic spellings of
a widened Secret grant left that assert green: a wildcard in resources,
a wildcard in apiGroups, a "*" appended to the declared verb list, an
extra field beside the verbs, deletecollection spelled out, and two
where the grant is added as a separate rule. Those last two leave the
whole suite green - appending apiGroups:['*'] resources:['*']
verbs:['*'] keeps the positive pin satisfied while the controller gains
every verb on every Secret cluster-wide.

Replace it with a bats guard over the rendered manifests. It unions the
verbs that every ClusterRole and Role rule confers on core Secrets,
expanding "*" on each of the three axes, and compares that union with
the declared set. Equality rather than an upper bound: the controller is
cluster-scoped, so a widening reaches every tenant namespace, and a
narrowing breaks the two reconcilers that share the grant.

The positive pin stays in tests/rbac_test.yaml. Value equality is the
right primitive for pinning a rule as written and the wrong one for
bounding what the rule may become.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-08-12 18:37:09 +03:00
Aleksei Sviridkin 37a91f98b8 feat(cozystack-controller): extract application CA into a key-free tenant Secret
Every catalog engine issues a per-release CA, but the object holding
ca.crt usually holds a private key beside it (cert-manager's tls.key,
CloudNativePG's ca.key), so granting a tenant read on it hands over key
material too. Add a controller that publishes the trust anchor as one
canonical, key-free Secret per release, "<release>.tenant-ca", holding
only ca.crt.

A chart declares the anchor by rendering a namespaced TenantProjection
sentinel (internal.cozystack.io/v1alpha1) that names the source Secret
and key. The controller rebuilds ca.crt from the parsed certificate DER
rather than copying the source, refuses any value carrying private key
material, and owns the projection by owner reference so a foreign Secret
at the same name is never overwritten. No tenant RBAC grants any verb on
internal.cozystack.io; a ValidatingAdmissionPolicy pins writes to
helm-controller as defence in depth.

The controller does not grant tenant read access — the lineage webhook
does, from the ApplicationDefinition's spec.secrets. This side stamps the
engine-agnostic internal.cozystack.io/tenant-ca label and forces a
re-admission when those selectors change.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-07-21 23:59:48 +03:00
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