Skip to content

feat(edge): EdgeRoute CRD + live watch driving the edge route table - #237

Merged
bpalermo merged 1 commit into
mainfrom
feat/edge-route-crd
Jun 19, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/edge-route-crd

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

What

PR2 of the edge proxy plan (stacked on #236). Adds the EdgeRoute custom resource (config.aether.io/v1, namespaced) — external host → mesh service[:port] mappings the edge agent watches and projects into its xDS route table live, no redeploy — replacing the --expose flag as the primary exposure mechanism (it stays as a static seed).

Why a custom CRD (vs Gateway API)

Per the approved plan: a tiny CRD names the mesh service directly (service = ServiceAccount = registry key, no Service-object indirection) and reuses the controller-runtime + CRD machinery from #229. The edge agent is already a manager, so watching a small CR is far less code than even a subset of Gateway API conformance. The spec is shaped to migrate to Gateway API later if the full L7 vocabulary is wanted.

Highlights

  • Proto EdgeRouteSpec (hosts/service/port, protovalidate) in api/aether/config/v1 — edition 2024 opaque API, alongside MeshConfigSpec.
  • Typed CRD in common/apis/config/v1 — hand-written types + protojson jsonshim + deepcopy, registered on the shared config.aether.io scheme; lenient decode for rolling-upgrade forward-compat (same machinery as MeshConfig).
  • Chart — namespaced EdgeRoute CRD in charts/crds (permissive structural schema; authoritative validation is protovalidate). Chart 0.1.0 → 0.2.0.
  • Cache — cache.EdgeRoute + SetEdgeRoutes: scopes the dependency set to the referenced services and rebuilds the route table from the routes (even when only hostnames change). Host→cluster resolution picks default vs per-port cluster; routes to the same cluster merge into one vhost (Envoy NACKs duplicate vhost names/domains).
  • Agent — a level-based EdgeRoute reconciler (re-lists each reconcile) merges CRs with the --expose seed and pushes the full set into the cache. runEdge builds the manager scheme, scopes its informer cache to the watched namespace (namespaced RBAC), seeds routes up front, and registers the reconciler.

Example

apiVersion: config.aether.io/v1
kind: EdgeRoute
metadata: { name: api, namespace: aether-edge }
spec:
  hosts: [api.example.com]
  service: svc-1
  port: 8080   # optional; omit = default port

Tests

EdgeRoute JSON round-trip + lenient decode + deepcopy; cache SetEdgeRoutes dependency set + host/port cluster resolution + vhost merge; reconciler projection (namespace filtering, seed merge, inert-route skip) via the controller-runtime fake client.

bazel build //..., bazel test //agent/... //common/... //api/... //controller/... //registry/... (31/31), --config=lint, make format, and scripts/check-chart-version-bump.sh all pass. Both CRDs render via helm template.

Follow-ups

  • PR3: edge chart (edge.enabled in charts/aether; bootstrap defining the spire_agent SDS cluster; RBAC for the EdgeRoute watch).
  • PR4: downstream TLS termination.
  • PR5: talos e2e.

🤖 Generated with Claude Code

Replace the edge proxy's static --expose seed as the sole exposure mechanism
with an EdgeRoute custom resource (config.aether.io/v1, namespaced): external
host -> mesh service[:port] mappings the edge agent watches and projects into its
xDS route table live, with no redeploy.

- api/aether/config/v1: EdgeRouteSpec proto (hosts/service/port, protovalidate),
  edition 2024 opaque API alongside MeshConfigSpec.
- common/apis/config/v1: hand-written typed EdgeRoute CRD (types + protojson
  jsonshim + deepcopy), registered on the shared config.aether.io scheme; lenient
  decode for rolling-upgrade forward-compat — same machinery as MeshConfig.
- charts/crds: namespaced EdgeRoute CRD (permissive structural schema; authoritative
  validation is protovalidate). Chart version 0.1.0 -> 0.2.0.
- snapshot cache: cache.EdgeRoute + SetEdgeRoutes scopes the dependency set to the
  referenced services and rebuilds the edge route table from the routes (even when
  only hostnames change). Host->cluster resolution picks the default vs per-port
  cluster; routes to the same cluster merge into one vhost (Envoy NACKs duplicate
  vhost names/domains).
- agent: an EdgeRoute reconciler (level-based: re-lists each reconcile) merges the
  CRs with the --expose static seed and pushes the full set into the cache. runEdge
  builds the manager scheme, scopes its informer cache to the watched namespace
  (namespaced RBAC), seeds routes up front, and registers the reconciler.

Tests: EdgeRoute JSON round-trip + lenient decode + deepcopy; cache SetEdgeRoutes
dependency set + host/port cluster resolution + vhost merge; reconciler projection
(namespace filtering, seed merge, inert-route skip) via the controller-runtime fake
client.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Pihqn5RmVPhV9HTdBnqbvY
@bpalermo
bpalermo merged commit efb49ed into main Jun 19, 2026
14 checks passed
@bpalermo
bpalermo deleted the feat/edge-route-crd branch June 19, 2026 16:02
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.

1 participant