Repository navigation
docs(networking): document endpoint attachments - #825
Open
Timofei Larkin (lllamnyp) wants to merge 1 commit into
Open
Timofei Larkin (lllamnyp) wants to merge 1 commit into
Timofei Larkin (lllamnyp) wants to merge 1 commit into
Conversation
Timofei Larkin (lllamnyp)
requested review from
Andrei Kvapil (kvaps),
myasnikovdaniil and
Timur Tukaev (tym83)
as code owners
November 26, 2026 14:40
✅ Deploy Preview for cozystack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Merged
1 of 12 tasks
Timofei Larkin (lllamnyp)
added a commit
to cozystack/community
that referenced
this pull request
Nov 27, 2026
…ber as implemented The proposal now specifies EndpointAttachment as cozystack/cozystack#4324 implements it: the loadBalancer member only, with gateway a reserved member name. The gateway member and the Gateway API material move to design-proposals/endpoint-attachments-gateway, proposed separately and stacked on this one. Changes to the text, each taken from #4324 and its user guide (cozystack/website#825): - cozy-proxy exclusivity is one delegated Service per backend pod in either mode, with a chart Service rendered by external: true always winning; the PortList-beside-external e2e case is gone. - WholeIP on several backends keeps its Service and claim and selects nothing, instead of being refused. - A minted claim is deleted with its attachment, and its address follows the class's reclaim policy (Retain by default). - New: IP family rendering on the Service, the cozy-proxy platform declaration, the cozyplane FloatingIP path and its refusals, the refusal of tenant-cluster cloud-controller-manager Services and selectorless endpoints, the conditions table, status.claimName, and the tenant RBAC. - loadBalancerClass comes from IPAddressClass.spec.loadBalancerClass (address-controller v0.2.0), and the text notes that #35 decision 0003 says otherwise. - Security states that spec.services is the publish gate, that class selection is not authorized per tenant, and that an attachment does not enable a database's TLS. - The claim that no platform path recreates a tenant HelmRelease is corrected (postRestoreRename, migration 28). - Status and Date fields are removed, per design-proposals/README.md. Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2 tasks done
Timofei Larkin (lllamnyp)
force-pushed
the
docs/endpoint-attachments
branch
from
November 27, 2026 06:30
67d7f8f to
36c4b7b
Compare
EndpointAttachment gives one tenant-facing Service of a managed application its own external address from the address substrate, minted from an IPAddressClass or bound from a reserved IPAddressClaim. The new page covers which Services can be attached, what the controller renders, the address lifecycle, conditions, TLS, the VM datapath modes and the cozyplane FloatingIP path. Which Services are attachable is ApplicationDefinition.spec.services, so the ApplicationDefinition page now describes that selection and the tenant-facing marker it sets. The reserved-IP page documents the loadBalancerClass and Accepted condition a class's provisioner reports in status from address-controller v0.3.0, and points managed applications at endpoint attachments. Refs: cozystack/cozystack#4324 Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Timofei Larkin (lllamnyp)
force-pushed
the
docs/endpoint-attachments
branch
from
November 27, 2026 07:35
36c4b7b to
f512cb0
Compare
Aleksei Sviridkin (lexfrei)
added a commit
to cozystack/cozystack
that referenced
this pull request
Nov 27, 2026
#4324) ## What this PR does Implements `EndpointAttachment` (`local.sdn.cozystack.io/v1alpha1`, namespaced) from the design proposal in [cozystack/community#45](cozystack/community#45): a tenant-created resource that attaches one external address to one tenant-facing Service of one managed application. It is the Network load-balancing path (a dedicated address per attachment), complementary to SNI exposure through the tenant Gateway, and it implements the `loadBalancer` union member only. Nothing in it routes by hostname, touches TLS, or reads chart values. Two commits. The first updates address-controller and metallb-iad to v0.3.0: the class's provisioner now reports, in `IPAddressClass.status.loadBalancerClass` with an `Accepted` condition for the class's generation, the `loadBalancerClass` a Service consuming its claims must carry, and the MetalLB driver writes that status. The second adds `EndpointAttachment`, which sets that class on every Service and FloatingIP it renders and renders nothing new until the class is accepted (`ClassNotAccepted`); a Service or FloatingIP already published is kept if the class later loses acceptance. The FloatingIP retarget check needs cozyplane v0.1.5 or later, which stamps `metadata.generation` and `status.observedGeneration`. [#5389](#5389) moves the cozyplane pin to v0.1.5, and this PR merges after it; on an older cozyplane both fields read 0 and the check passes as before. **API** (`api/localsdn/v1alpha1/endpointattachment_types.go`, CRD generated into the cozystack-controller chart). The kind lives in `local.sdn.cozystack.io`, the CRD-served half of the sdn family the address substrate and cozyplane already share, so stock `ResourceQuota` counts still work. `spec` is required at the resource root, since removing it would otherwise skip every rule nested inside it. `spec.applicationRef` (group/kind/name, group defaulting to `apps.cozystack.io`), `spec.endpoint.serviceName`, and `spec.loadBalancer` with `className` | `claimName` (exclusive), `family`, `ports`, `method` (`WholeIP` | `PortList`), `allowICMP`. CEL freezes the address-identity fields (`applicationRef`, `className`, `claimName`, `family`) and the member selection, requires exactly one union member (written as a list so a `gateway` member can be added without restructuring), and holds the static shape rules (`PortList` needs `ports`, `allowICMP` is `PortList`-only). Everything cross-object or dynamic is a condition. `status.phase` is a projection of the `Resolved` and `Provisioned` conditions. **Controller** (`internal/controller/endpointattachment`), one reconcile in four steps: 1. Resolve. The application's HelmRelease is found by the three lineage labels; the attachment gets a non-controller owner reference to it by UID and the lineage labels stamped on itself. The endpoint Service must carry the lineage triple matching `applicationRef` and `internal.cozystack.io/tenantresource: "true"`; lineage alone is refused (`EndpointLineageMismatch` / `EndpointNotTenantFacing`), as is a Service rendered by another attachment, and a LoadBalancer Service a tenant Kubernetes cluster's cloud-controller-manager creates for a Service inside that cluster: it carries the cluster's lineage and the marker, and is told apart by the `cluster.x-k8s.io/tenant-service-name` label that controller writes. A same-name recreated application (different HelmRelease UID) is reported as `ApplicationIncarnationChanged`, the Service is withdrawn, and the owner reference is never rewritten. 2. Claim. `claimName` references an existing `IPAddressClaim` and writes nothing to it; otherwise a claim is minted with `generateName` under the attachment's controller reference. The substrate kinds are read as unstructured, so the controller carries no module or CRD dependency on it and reports `ClaimPending` where it is not installed. `loadBalancerClass` is read from the claim's resolved `IPAddressClass` status before the Service is created, only once the class's `Accepted` condition is True for its current generation, and left empty when the class reports the cluster default. The Service's `ipFamilyPolicy` and `ipFamilies` follow the claim's family (`SingleStack` for IPv4 or IPv6, `RequireDualStack` for Dual) and are reconciled on existing Services; a primary family that differs, which the apiserver never changes, and a create the cluster refuses are both reported as `RenderFailed`. An address whose `IPAddress.status.associatedTo` names another live Service gives `ClaimInUse` and withdraws this attachment's own Service, so two attachments that both rendered before either association was recorded leave one Service asking for the claim. A `family` conflicting with a referenced claim gives `FamilyConflict`. 3. Render. One `type: LoadBalancer` Service via `generateName` (a prefix derived from the attachment name and bounded to what the apiserver accepts for a Service, which also bounds the minted claim's), identified by controller owner reference only (a Service with the ownership label and no reference is ignored, never adopted). It mirrors the endpoint's selector and ports (or the `ports` subset; synthesized ports when the endpoint has only the sentinel port), carries the `local.sdn.cozystack.io/ip-address-claim` annotation, `externalTrafficPolicy: Local`, and `allocateLoadBalancerNodePorts: false` unless the platform says otherwise. It copies no labels or annotations from the endpoint. An endpoint with no selector (hand-managed endpoints) is refused with `NothingToPublish`, and the VM placeholder is recognised by its shape (headless, only port 65535) rather than by the port alone. When the cache shows no owned Service, the controller rechecks through the API reader before creating one, and collapses duplicates to the oldest. Re-mirroring is event-driven through watches on Services, EndpointSlices, HelmReleases and, where served at startup, the claim kind. 4. Report. `status.addresses` mirrors the claim's bound addresses (a list), `status.serviceName` and `status.claimName` name the objects, and `Provisioned=True` asserts address and Service wiring only; its message says so, since reachability additionally depends on the CNI's policy objects. **VM datapath modes.** `method` renders the cozy-proxy Service contract exactly (the `service.kubernetes.io/service-proxy-name: cozy-proxy` label, `networking.cozystack.io/wholeIP`, `networking.cozystack.io/allowICMP`, the sentinel port for whole-IP without ports) and adds nothing beside it. Rendering is gated on a platform declaration, not CNI detection: the controller flag `--cozy-proxy-contract-implemented` is threaded from the system bundle, which sets it exactly when it emits the cozy-proxy Package; without it a method-bearing attachment renders no Service and reports `DatapathContractUnavailable`, because a load balancer would still attract the address while every proxy skipped the Service. Exclusivity is keyed on the backend pod and counts every delegated Service in either mode (attachments, chart Services rendered with `external: true`, hand-made ones): a delegation no attachment renders (a chart Service with `external: true`, or a hand-made one) always wins, since nothing would ever withdraw it; between attachments the oldest wins, ties by name. The loser reports `BackendAlreadyDelegated` and renders nothing rather than fighting for the slot. cozy-proxy v0.4.0 programs IPv4 only (one IPv4 nftables table, every address through `To4()`), so a method attachment off a VPC with an `IPv6` or `Dual` claim renders no Service and reports `FamilyUnsupportedByDatapath`; the cozyplane path still serves IPv6 through the FloatingIP. `WholeIP` on an endpoint with more than one ready backend keeps its Service and claim but selects nothing (`MultipleBackends`), so a rolling update or live migration passes through held-but-dark and recovers without churning the address. **VMs in a VPC.** On a cozyplane VPC the VM's only interface is in the VPC, so the launcher pod address a cozy-proxy Service maps to never reaches it. When a backend pod carries the VM chart's `sdn.cozystack.io/vpc` annotation and the cluster serves cozyplane's `FloatingIP`, a `WholeIP` attachment owns a FloatingIP in its namespace (`vpcRef` from the annotation, `target` from the `sdn.cozystack.io/vpc-ip` address cozyplane's CNI stamps, `addressClaimName` the attachment's claim) instead of a Service, and `Provisioned` mirrors the FloatingIP's readiness. FloatingIP is read as unstructured and only where served, so there is no dependency on the cozyplane PR. Refusals there: `PortList` (`MethodUnsupportedInVPC`), a `Dual` claim, since a FloatingIP wears one address (`DualStackUnsupportedInVPC`), a VPC in another namespace (`VPCNotInNamespace`), several distinct VPC addresses or a mix of VPC and non-VPC pods (`MultipleBackends`, claim held), no VPC address stamped yet (`WaitingForVPCAddress`), and a VPC backend where FloatingIP is not served (`DatapathContractUnavailable`, no Service). A live migration's two launcher pods share the VPC address and stay one binding; a stopped VM keeps its FloatingIP. Since only a backend pod says whether a VM is in a VPC, a `method` attachment that has published nothing yet waits for one (`WaitingForBackend`), so an attachment created before its VM starts never pins the claim to a cozy-proxy Service first. On the kube-ovn VPC the VM keeps its pod-network interface and joins VPC subnets through extra interfaces, so the cozy-proxy path is unchanged there. **Detach semantics.** An endpoint Service that disappears withdraws the rendered Service, keeps the claim (minted or referenced), and reports `Detached`; the same claim is reused when the endpoint returns. Deleting an attachment collects its Service and its minted claim; a referenced claim is untouched. **Wiring.** The controller is registered in `cmd/cozystack-controller` behind two flags (`--cozy-proxy-contract-implemented`, `--endpoint-attachment-allocate-node-ports`), the chart exposes them as `cozystackController.endpointAttachments.*`, the platform system bundle derives both (cozy-proxy emitted, Hetzner RobotLB enabled), the controller ClusterRole gains Service writes, the `endpointattachments` kind, `ipaddressclaims` create/delete and `sdn.cozystack.io` `floatingips` writes, and the tenant ClusterRoles get `endpointattachments` beside `securitygroups` (full in `cozy:tenant:base`, read in `cozy:tenant:view:base`, write in `cozy:tenant:admin:base`). **Tests.** `crdcel_test.go` compiles the shipped CRD and pins the create and update admission matrix. `reconciler_test.go` (fake client) covers the resolve/deny matrix over both label families, mirroring and port subsetting, the minted-claim path, the two proof sequences (a labelled-but-unowned Service is ignored and a same-name recreated application is not re-acquired; a reserved claim holds across detachment and moves to a different application), detach/reattach, the sentinel-port rule, the capability gate, both modes, held-but-dark on multiple backends, pod-keyed exclusivity, the substrate-absent path and the family conflict. Admission tests also validate from the resource root (removing or restoring `spec`). The reconciler tests cover a Dual claim that is provisioned only once the Service carries both addresses, and attachment names up to 253 characters, with dots or a leading digit, on both address-selection paths. `floatingip_test.go` covers the cozyplane path: the FloatingIP's spec and readiness mirroring, the claim worn by its own Service not counting as in use, switching from and back to a cozy-proxy Service, a kube-ovn-shaped backend keeping the Service, each refusal, live migration, a stopped VM, re-pointing in place, detach and name bounds. Chart unit tests pin the platform declaration on every bundle variant, slim opt-in included, and the FloatingIP RBAC rule. `hack/e2e-chainsaw/endpointattachment` carries the postgres hold/move sequence, GC, the lineage refusal of an attachment pointing at another application's Service, and the VM mode Test (re-scoped to a single delegated Service per VM, since current cozy-proxy's rule installer keeps one 1:1 slot per pod). It is registered: `hack/select-install.sh` maps it to `cozystack.address-controller` and `cozystack.metallb-iad`, with Postgres, VMInstance, VMDisk and cozy-proxy as its runtime requirements, and `hack/select-e2e.sh` maps both substrate packages back to it, since no other suite installs them. The e2e install enables both packages, and `hack/e2e-post-install-prep.sh` creates the default `IPAddressClass` on a dedicated, non-auto-assigning MetalLB pool whenever metallb-iad is installed. `hack/e2e-chainsaw/endpointattachment-vpc` covers the cozyplane FloatingIP path (whole-IP published through a FloatingIP, `PortList` and `Dual` refused) and stays parked as `chainsaw-test.yaml.disabled`, because no e2e lane installs the cozyplane networking variant. **Upgrade.** Additive: a new CRD, a new reconciler, new RBAC rules, no migration. The system bundle now always passes the cozystack-controller component an `endpointAttachments` values block, so the first upgrade rolls the controller once with the new flags; the flags change nothing until `EndpointAttachment` objects exist, and no existing object is modified. **Docs.** The user guide is on the website, in [cozystack/website#825](cozystack/website#825): the resource, which Services can be attached, the lifecycle, the conditions' exact meaning, the VM modes and the cozyplane path, and the TLS posture (attaching a database does not turn its TLS on). It is a cross-package guide, so under the documentation placement rules it lives there rather than in `docs/`. **Not in this PR, deliberately.** The `gateway` union member (a reserved name; the CRD ships without it and nothing references it). A certSAN write-back for the managed Kubernetes API. Discovery-engine address write-back. The address-preserving migration from `external: true`. An authoritative exclusivity gate inside cozy-proxy (the attachment-side refusal is advisory); that wants an issue in cozystack/cozy-proxy. ### Screenshots Not a UI change. ### Downstream repositories `ApplicationDefinition.spec.services` now also decides which Services tenants can attach an address to, which the trigger map routes to the website's ApplicationDefinition page: [cozystack/website#825](cozystack/website#825) documents that, and carries the user guide. Nothing else matched: the cozy-proxy runtime contract is consumed with the same three literal strings and nothing is renamed; the new CRD travels as opaque JSON in the terraform provider; no platform `values.yaml` key, variant, asset or node prerequisite changed. An issue in cozy-proxy for an authoritative one-delegation-per-pod gate is worth a human decision rather than a speculative filing. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#825 - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(api): add EndpointAttachment (local.sdn.cozystack.io/v1alpha1), a tenant resource that attaches an external address, minted from an IPAddressClass or bound from a reserved IPAddressClaim, to one tenant-facing Service of a managed application by rendering an additive LoadBalancer Service that mirrors it; VM whole-IP and port-list modes render the cozy-proxy contract where the platform deploys it. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added endpoint attachments to publish eligible application and VM endpoints through dedicated load balancer addresses, with whole-IP or selected-port exposure and IPv4, IPv6, or dual-stack support. * Attachments can use a reserved address or request one through a configured address class. Status shows endpoint resolution, provisioning, assigned addresses, and attachment state. * Tenant access now includes managing and inspecting endpoint attachments. Whole-IP VM exposure is limited to one delegated backend, and VPC support depends on the available network datapath. * **Documentation** * Added guidance on eligible endpoints, address lifecycle, status, and exposure considerations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents
EndpointAttachmentfrom cozystack/cozystack#4324 in thenext/trunk, where it waits for the release that ships the feature.networking/endpoint-attachments.md(new): the user guide. It covers which Services can be attached, what the controller renders (theloadBalancerClassthe class reports in status, waiting for the class'sAcceptedcondition, and IP families from the claim), the IPv4-only cozy-proxy rule, the address lifecycle, conditions, TLS, the VM datapath modes through cozy-proxy, and the cozyplaneFloatingIPpath with its refusals.cozystack-api/application-definitions.md: a new section onspec.services. It decides which Services the lineage webhook marks tenant-facing, and with #4324 that is also the list of Services anEndpointAttachmentcan attach to.networking/reserved-ip-addresses.md: documents what a class's provisioner reports in status from address-controller v0.3.0 (status.loadBalancerClassand theAcceptedcondition, withPoolRefusedfor an unusable pool; #4324 bumps to v0.3.0), and replaces "Managed applications do not expose the annotation yet" with a link to the new page.The guide was written for #4324 as an in-repo document; it moves here under the cozystack documentation placement rules, and #4324 drops its copy.
Pages under
next/are excluded from production builds, so merging this before #4324 publishes nothing; the Netlify deploy preview renders them.