Skip to content

feat(edge): Add public listeners for Edge providers - #1514

Merged
privateip merged 1 commit into
mainfrom
fix/issue-1508
Nov 28, 2026
Merged

privateip merged 1 commit into
mainfrom
fix/issue-1508

Conversation

@privateip

@privateip privateip commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The platform can now give an Edge provider public listeners, though nothing serves one yet. Existing gateway services and providers behave as before, and providers cannot write listeners or gateway services.

Merging this reaches the staging labs, which track main, first, and production edge sites only after a release tag.

Test plan

  • Envtest covers the listener schema, the exactly-one backend rule and the two admission policies
  • Unit test covers a gateway service that names a listener
  • task lint, task build, task test:unit and task docs:check pass

Fixes #1508

@privateip privateip self-assigned this Nov 28, 2026
@privateip

privateip commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

What changes

  • PublicListener joins the capability enums on EdgeProvider and EdgeService. The EdgeService limit rises from 3 to 4, and core's supportedCapabilities gains PublicListener v1. An EdgeAttachment still accepts only SocketAccess and PacketAccess.
  • New EdgeListener with these fields:
    • immutable providerRef and serviceRef
    • at most one address per family
    • 1 to 16 ports, where two ports of one protocol cannot share a backendPort
    • healthPort, required when every port is UDP
    • sessionAffinity, defaulting to ClientIPAndProtocol, and failurePolicy, defaulting to FailOpen
    • status with Accepted, Programmed, the design's reason constants, and per-backend entries
  • NetworkService.spec.edgeListenerRef. Exactly one of backendSelector and edgeListenerRef is required, and a backendSelector that is set must not be empty. backendSelector keeps its value type with omitzero, since network-services-operator builds it by value.
  • internal/controller/rulebackends.go gives a service with edgeListenerRef no backends and reports its listener pending. Without this, it would fail on the empty-selector check.
  • The galactic-edge-provider-listener policy refuses writes to edgelisteners and networkservices, and their status, by any ServiceAccount an EdgeProvider lists. One binding with paramRef.selector: {} checks every provider.
  • The galactic-edge-listener-namespace policy keeps EdgeListener objects and edgeListenerRef in galactic-system.
  • galactic-edge-listener-authority is an unbound ClusterRole for writing EdgeListeners.
  • The provider contract, API reference and design status are updated.

Choices to review

  1. serviceRef takes namespace and name only, as in the design, with no UID pin like the one EdgeAttachment.serviceRef has.
  2. failurePolicy defaults to FailOpen, the same default as NetworkService. The design's example uses FailClosed but states no default.
  3. The backendPort uniqueness rule is not in the design. It follows from the reply path: a backend's reply is translated back to one public port.

Risk

Tests

  • TestEdgeListenerSchema and TestPublicListenerCapability (envtest) cover the enums, addresses, ports, the all-UDP rule, defaults, immutability and the status subresource.
  • TestNetworkServiceBackendSource and TestNetworkServiceOmitsEmptySelector cover the exactly-one rule and the encoding it relies on.
  • TestListenerPolicies (envtest with the shipped policies) checks that a provider's writes are refused, another ServiceAccount's are allowed, and listeners stay in galactic-system.
  • TestSelectRuleBackends_EdgeListenerHasNoBackends fails before the gateway change and passes after it.

Local runs passed: task lint, task build, task test:unit with envtest, task test:e2e and task docs:check.

@privateip privateip changed the title feat(edge): Let the platform give Edge providers public listeners feat(edge): Add public listeners for Edge providers Nov 28, 2026
@privateip
privateip marked this pull request as ready for review November 28, 2026 14:55
@privateip
privateip requested a review from a team as a code owner November 28, 2026 14:55
@privateip
privateip enabled auto-merge November 28, 2026 14:55
@privateip

privateip commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Review record for this PR, two passes by two reviewers.

First pass at 786cb61. pr-adversary returned merge; it ran go build, go vet, the listener, NetworkService and policy envtests, and go test ./internal/edge/.... pr-conventions-reviewer returned hold on one decision, the overlap with draft #845. The human decided this PR lands first and #845 reconciles the backendSelector rule when it lands. Fixes applied in f49685b and in the PR title, body and first comment: the #1465 regeneration note, a shorter body, the staging-first note, a documented galactic-system assumption in the namespace policy, and a new title.

Second pass at f49685b. pr-rereviewer returned merge, confirming all five applied findings are fixed; it ran git diff and git log over the fix and gh pr view. pr-conventions-reviewer returned merge; it ran kustomize build on config/galactic-edge and config/crd, task docs:check-generated, the full diff, and an open-PR overlap check. Nothing above nit remained.

Both nits are now applied: f49685b was squashed into one commit, 6725484, with the same tree, which also removes the 59-character subject.

Local runs before publishing: task lint, task build, task test:unit with envtest, task test:e2e and task docs:check all passed.

CI on f49685b: 26 checks passed and 2 were skipped, none failed. CI reruns on 6725484.

Auto-merge is enabled with the merge method, which is the only method the base branch ruleset allows. The ruleset requires one approving review, code owner review and approval of the last push, so the PR waits for a human approval.

ecv
ecv previously approved these changes Nov 28, 2026

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

API-only change that implements the merged design's Phase 1 and serves nothing: gateways give an edgeListenerRef service no backends, so no VIP is advertised and nothing is reachable. The safety of the merge rests on these claims:

  1. A provider ServiceAccount cannot create, change, delete or write the status of an EdgeListener or NetworkService: galactic-edge-provider-listener (policies.yaml) denies every ServiceAccount an EdgeProvider lists, and galactic-edge-listener-authority is an unbound ClusterRole. TestListenerPolicies exercises the shipped policy (create, update, status, delete, listener and selector services). It runs as the shipped VAP only, not with RBAC.
  2. EdgeListener, and any NetworkService with edgeListenerRef, exist only in galactic-system (galactic-edge-listener-namespace, tested for both kinds), so a project namespace cannot take a provider's backends.
  3. Nothing is served: ruleCandidateBackends returns no backends and a pending reason for edgeListenerRef, covered by TestSelectRuleBackends_EdgeListenerHasNoBackends. The NetworkService rule is exactly one of backendSelector and edgeListenerRef, with the non-empty rule kept, and TestNetworkServiceBackendSource and TestNetworkServiceOmitsEmptySelector cover it.
  4. Addresses, ports and the provider are platform-set: the spec is writable only by whoever the operator binds the authority role to, and providerRef and serviceRef are immutable by CEL. The address pool, claim and grant checks (AddressOutsidePool, AddressClaimed, CapabilityNotGranted) are only status constants here; core enforces them in a later phase, and nothing in this PR does.

Follow-ups:

  • Phase 2 (core) must be the first thing that makes an EdgeListener serve anything, and it must carry the address-pool, cross-listener claim and serviceRef grant checks with envtest cases before gateways resolve listener backends in phase 4. Today a spec can name any serviceRef namespace (another tenant's gVPC) or any address, and only the write path stops it.
  • The policy denies only ServiceAccounts an EdgeProvider lists and only matches system:serviceaccount: users, like the other edge policies. A provider's own ability to edit its EdgeProvider.spec.serviceAccounts is therefore load-bearing for claim 1: confirm that is already refused, and add a test line if so.
  • Source spoofing from another gVPC's addresses is not touched here. It rests on the existing attachment datapath and traffic policy, and design goal 6 should get a negative packet test in phase 3, as its table already says.
  • The follow-ups raised on #1513 are half handled: EdgeListenerPort.protocol is lowercase tcp/udp, matching NetworkService, so no mapping is needed, but the design's YAML example still uses UDP/TCP and a per-port name the CRD does not have, so it would not be admitted as written. drainSeconds is still not explained in the API text; spell out that it also keeps a draining backend selectable.
  • serviceRef has no UID pin, unlike EdgeAttachment.serviceRef, as the body says. A delete and recreate of the EdgeService under the same name keeps the grant; fine while the authority is trusted, worth a pin when core lands.

Add EdgeListener, the public addresses and ports the platform gives one
provider, and the PublicListener capability on EdgeProvider and
EdgeService. Core implements PublicListener v1; an EdgeAttachment still
takes only SocketAccess and PacketAccess.

NetworkService gains edgeListenerRef. Exactly one of backendSelector and
edgeListenerRef is required. backendSelector keeps its value type with
omitzero, so callers that build it by value compile unchanged. Until
gateways resolve listener backends, a service with edgeListenerRef has
no backends and is reported pending instead of failing on an empty
selector.

Two admission policies refuse any provider ServiceAccount write to an
EdgeListener or NetworkService, and keep listeners and services naming
one in galactic-system, which the policy assumes is the gateway
namespace. An unbound ClusterRole lets an operator grant the platform
authority write access to EdgeListeners.

Fixes #1508

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

Re-review at d907bb8: a rebase onto main after #1515 merged. The PR's own diff is unchanged except the design status line, which now keeps both the Phase 0 result and the Phase 1 API statement. The earlier follow-ups stand.

@privateip
privateip merged commit 2a0dd12 into main Nov 28, 2026
28 checks passed
@privateip
privateip deleted the fix/issue-1508 branch November 28, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the Edge public listener API

2 participants