Plan: hub architecture — portable as hub, WireGuard mesh + Cilium Gateway API edge + shared CA #1532

Open
opened 2026-08-13 22:58:59 +00:00 by ginjiruu · 5 comments
Owner

Hub architecture plan: portable as hub — WireGuard mesh + agentgateway ingress + shared CA

End-state architecture for the fleet: one hub cluster with a public IP, WireGuard between sites, agentgateway as the single ingress for every cluster, Cilium ClusterMesh over the WG fabric, Kanidm as the identity store, shared CA with Vault as authority. This ticket is the plan; implementation lands as child tickets. Supersedes the OCM adoption discussion — OCM's tunnel is rejected; we build the tunnel ourselves.

Goal

Any client with internet access and a valid Kanidm identity can reach any cluster's Kubernetes API, authenticated and audited, over <cluster>.k8s.animeteamspeak.moe. All "client" access (argocd, vault, sveltos, tofu-controller, humans) goes through agentgateway.

Decisions

D1. Hub = portable

Portable holds the public IP and is the WireGuard coordination point + the single agentgateway ingress for all clusters. Portable is currently resource-starved → running workloads move off portable onto mini as part of this plan. mini is not publicly reachable; it joins as a spoke.

D2. WireGuard/UDP everywhere (assumption)

Assumption: WireGuard/UDP works at all current target sites. If a site turns out TCP-egress-only, revisit (frp/rathole for L4, UDP-over-TCP shim or L3 alternative for ClusterMesh). Not yet validated per site.

D3. Shared CA, Vault as authority

All clusters share one apiserver CA. Vault is the CA authority (tried and tested). cert-manager trust-manager distributes the CA bundle; agentgateway trusts the shared CA for backendTLS. One bundle, one trust policy.

Because the CA is shared, it must be pre-seeded into every cluster before the first server starts (RKE2 generates its own CA at first start and will not adopt one afterward without a disruptive re-sign):

  • Vault issues the CA; the key + cert are a secret value owner decision (human or Vault IaC seeds them — a Vault KV path), not collected off a live server.
  • The material is laid into /var/lib/rancher/rke2/server/tls/ by the machine-configs rke2 module before rke2-server starts (nix repo requirement R7).
  • Distribution of the CA cert (only) to agentgateway backendTLS is post-bootstrap via Vault → trust-manager; the CA key never leaves sops / Vault IaC.

D4. OIDC flags on every apiserver

Every apiserver carries the OIDC flags from #1522 (issuer, client-id, groups-claim, username-claim) and grants by capability groups (iac#2 / ADR-0006). This is a machine-configs change (kube-apiserver-arg), not an agentgateway concern.

D5. Single public endpoint per cluster, dual auth

Public URL per cluster: <cluster>.k8s.animeteamspeak.moe. One endpoint serves both flows:

  • Machine: kubeconfig carries a Kanidm SA API token (the only secret) + agentgateway server/CA → agentgateway performs the RFC 8693 exchange per request (Golden Path, iac#38/#39).
  • Human: kubelogin exec mints a fresh token client-side → agentgateway passes it through; apiserver validates OIDC directly.

Assumption: agentgateway supports multiple auth configurations on a single endpoint (precedent: kgateway / envoy-gateway). Validate; expected upstream if not present today.

D6. WebSocket/SPDY validation

kubectl exec/logs/port-forward use connection upgrades. konnectivity only solves hub→spoke, not client→cluster, so the client→cluster upgrade path must work through agentgateway. Validate before depending on it.

D7. DNS

<cluster>.k8s.animeteamspeak.moe records managed via the existing external-dns config. Portable is the single gateway → a fallback *.k8s.animeteamspeak.moe record covers new clusters until per-cluster records exist.

D8. Audit

Audit was an offhand comment about what this architecture yields — a capability, not a v1 commitment. Out of scope for the plan.

D9. Bootstrap requirements → machine-configs

The Nix bootstrap requirements this plan imposes are written to the machine-configs repo (docs/architecture-requirements.md). See pointer under Bootstrap.

D10. Shared site network — own ticket

A proper shared-site-network address plan (WG overlay vs routed site LANs; tls-san; ipv4NativeRoutingCIDR) is tracked as its own ticket: #1533.

Architecture

Topology

  • Hub: portable (public IP, WG coordination point, agentgateway ingress, external-dns, trust-manager).
  • Spokes: mini, think, epsilon, future sites; each runs a WG peer dialing portable.
  • WG: VPN between all sites → the L3 path Cilium ClusterMesh rides.
  • Cilium ClusterMesh: application service sharing over the WG fabric (the #1528 pattern, extended to all reachable sites).

Connectivity planes

  • L3 fabric (WG) → ClusterMesh service sharing; pod CIDRs routable across sites.
  • L4 client access → agentgateway on portable → (WG) → target apiserver.

Auth flows

  • Machine: Kanidm SA API token → agentgateway exchange → apiserver OIDC + capability groups.
  • Human: kubelogin exec → fresh token → passthrough → apiserver OIDC + capability groups.
  • The kubernetes service in default is not a ClusterMesh global service (control-plane owned; unsupported).

Certificates

  • Ingress: Let's Encrypt for *.k8s.animeteamspeak.moe; no client-side CA distribution.
  • Backend: shared cluster CA via trust-manager; agentgateway backendTLS trusts it; serverName matches the internal SAN agentgateway dials (service name / VIP / WG address).

Bootstrap pipeline (machine-configs)

Written to docs/architecture-requirements.md in the machine-configs repo. Summary of the new pieces: OIDC flags (#1522), tls-san for the backend-dialed address, WG peer config + per-host keys (sops), tunnel client for firewalled/dev sites (frp/rathole), first-boot sops identity (SSH-host-key age + keys baked into the installer ISO), and the one-time CA export (rke2 server CA → Vault → trust-manager). The CA export is runtime, not Nix.

Open items / child tickets

  • Network plan (D10) — #1533
  • Validate agentgateway dual-auth on one endpoint (D5) — #1534 (prerequisite)
  • Vault as shared apiserver CA authority (D3) — iac#40
  • Validate exec/logs/port-forward through agentgateway (D6) — #1535
  • Validate WG/UDP at each site (D2) — #1536
  • Move workloads off portable onto mini (D1 prerequisite) — #1537
  • Implement agentgateway as hub ingress (D5/D6) — #1538 (gated on #1534/#1535)
  • Research: OCM inventory as the fleet registry (onboarding, 3→10) — #1539
  • #1522 k8s-apiserver OIDC flags
  • #1527 edge research, #1528 ClusterMesh implementation
  • #1529 Sveltos research, #1530/#1531 Sveltos auth + bootstrap
  • iac#2 catalog/capability-group spec, iac#28 (T13), iac#38 (Golden Path), iac#39 (resolved)
## Hub architecture plan: portable as hub — WireGuard mesh + agentgateway ingress + shared CA End-state architecture for the fleet: one hub cluster with a public IP, WireGuard between sites, agentgateway as the single ingress for every cluster, Cilium ClusterMesh over the WG fabric, Kanidm as the identity store, shared CA with Vault as authority. This ticket is the plan; implementation lands as child tickets. Supersedes the OCM adoption discussion — OCM's tunnel is rejected; we build the tunnel ourselves. ## Goal Any client with internet access and a valid Kanidm identity can reach any cluster's Kubernetes API, authenticated and audited, over `<cluster>.k8s.animeteamspeak.moe`. All "client" access (argocd, vault, sveltos, tofu-controller, humans) goes through agentgateway. ## Decisions ### D1. Hub = portable Portable holds the public IP and is the WireGuard coordination point + the single agentgateway ingress for all clusters. Portable is currently resource-starved → running workloads move off portable onto mini as part of this plan. mini is not publicly reachable; it joins as a spoke. ### D2. WireGuard/UDP everywhere (assumption) Assumption: WireGuard/UDP works at all current target sites. If a site turns out TCP-egress-only, revisit (frp/rathole for L4, UDP-over-TCP shim or L3 alternative for ClusterMesh). Not yet validated per site. ### D3. Shared CA, Vault as authority All clusters share one apiserver CA. Vault is the CA authority (tried and tested). cert-manager trust-manager distributes the CA bundle; agentgateway trusts the shared CA for `backendTLS`. One bundle, one trust policy. Because the CA is **shared**, it must be **pre-seeded** into every cluster before the first server starts (RKE2 generates its own CA at first start and will not adopt one afterward without a disruptive re-sign): - Vault issues the CA; the key + cert are a **secret value owner** decision (human or Vault IaC seeds them — a Vault KV path), not collected off a live server. - The material is laid into `/var/lib/rancher/rke2/server/tls/` by the machine-configs rke2 module **before** `rke2-server` starts (nix repo requirement R7). - Distribution of the CA *cert* (only) to agentgateway `backendTLS` is post-bootstrap via Vault → trust-manager; the CA *key* never leaves sops / Vault IaC. ### D4. OIDC flags on every apiserver Every apiserver carries the OIDC flags from #1522 (issuer, client-id, groups-claim, username-claim) and grants by capability groups (iac#2 / ADR-0006). This is a machine-configs change (`kube-apiserver-arg`), not an agentgateway concern. ### D5. Single public endpoint per cluster, dual auth Public URL per cluster: `<cluster>.k8s.animeteamspeak.moe`. One endpoint serves both flows: - **Machine**: kubeconfig carries a Kanidm SA API token (the only secret) + agentgateway server/CA → agentgateway performs the RFC 8693 exchange per request (Golden Path, iac#38/#39). - **Human**: kubelogin exec mints a fresh token client-side → agentgateway passes it through; apiserver validates OIDC directly. Assumption: agentgateway supports multiple auth configurations on a single endpoint (precedent: kgateway / envoy-gateway). Validate; expected upstream if not present today. ### D6. WebSocket/SPDY validation kubectl `exec`/`logs`/`port-forward` use connection upgrades. konnectivity only solves hub→spoke, not client→cluster, so the client→cluster upgrade path must work through agentgateway. Validate before depending on it. ### D7. DNS `<cluster>.k8s.animeteamspeak.moe` records managed via the existing external-dns config. Portable is the single gateway → a fallback `*.k8s.animeteamspeak.moe` record covers new clusters until per-cluster records exist. ### D8. Audit Audit was an offhand comment about what this architecture yields — a capability, not a v1 commitment. Out of scope for the plan. ### D9. Bootstrap requirements → machine-configs The Nix bootstrap requirements this plan imposes are written to the machine-configs repo (`docs/architecture-requirements.md`). See pointer under Bootstrap. ### D10. Shared site network — own ticket A proper shared-site-network address plan (WG overlay vs routed site LANs; `tls-san`; `ipv4NativeRoutingCIDR`) is tracked as its own ticket: #1533. ## Architecture ### Topology - **Hub**: portable (public IP, WG coordination point, agentgateway ingress, external-dns, trust-manager). - **Spokes**: mini, think, epsilon, future sites; each runs a WG peer dialing portable. - **WG**: VPN between all sites → the L3 path Cilium ClusterMesh rides. - **Cilium ClusterMesh**: application service sharing over the WG fabric (the #1528 pattern, extended to all reachable sites). ### Connectivity planes - **L3 fabric (WG)** → ClusterMesh service sharing; pod CIDRs routable across sites. - **L4 client access** → agentgateway on portable → (WG) → target apiserver. ### Auth flows - Machine: Kanidm SA API token → agentgateway exchange → apiserver OIDC + capability groups. - Human: kubelogin exec → fresh token → passthrough → apiserver OIDC + capability groups. - The `kubernetes` service in `default` is **not** a ClusterMesh global service (control-plane owned; unsupported). ### Certificates - **Ingress**: Let's Encrypt for `*.k8s.animeteamspeak.moe`; no client-side CA distribution. - **Backend**: shared cluster CA via trust-manager; agentgateway `backendTLS` trusts it; `serverName` matches the internal SAN agentgateway dials (service name / VIP / WG address). ## Bootstrap pipeline (machine-configs) Written to `docs/architecture-requirements.md` in the machine-configs repo. Summary of the new pieces: OIDC flags (#1522), `tls-san` for the backend-dialed address, WG peer config + per-host keys (sops), tunnel client for firewalled/dev sites (frp/rathole), first-boot sops identity (SSH-host-key age + keys baked into the installer ISO), and the one-time CA export (rke2 server CA → Vault → trust-manager). The CA export is runtime, not Nix. ## Open items / child tickets - **Network plan (D10)** — #1533 - **Validate agentgateway dual-auth on one endpoint (D5)** — #1534 (prerequisite) - **Vault as shared apiserver CA authority (D3)** — iac#40 - **Validate exec/logs/port-forward through agentgateway (D6)** — #1535 - **Validate WG/UDP at each site (D2)** — #1536 - **Move workloads off portable onto mini (D1 prerequisite)** — #1537 - **Implement agentgateway as hub ingress (D5/D6)** — #1538 (gated on #1534/#1535) - **Research: OCM inventory as the fleet registry (onboarding, 3→10)** — #1539 ## Related - #1522 k8s-apiserver OIDC flags - #1527 edge research, #1528 ClusterMesh implementation - #1529 Sveltos research, #1530/#1531 Sveltos auth + bootstrap - iac#2 catalog/capability-group spec, iac#28 (T13), iac#38 (Golden Path), iac#39 (resolved)
Author
Owner

Related new workstream (2026-08-18): plans/portable-offload-migration.md + #1537 (scope refined) + #1540 (backup-harness gate).

Refines D1: portable becomes the fleet's head management cluster — it keeps only management (forgejo, vault, harbor, kanidm) + networking/edge, and runs no web workloads. Everything else moves to mini (or standby/), gated on a file-based local-directory backup that is restore-tested (Velero kept as untrusted offsite copy only). This is what frees the capacity the hub roles (D2/D5/D6, #1533/#1534/#1535/#1538) need on portable.

One open call this raises for the hub: where Sveltos lives — see the comment on #1531.

Related new workstream (2026-08-18): `plans/portable-offload-migration.md` + #1537 (scope refined) + #1540 (backup-harness gate). Refines D1: portable becomes the fleet's *head management* cluster — it keeps only management (forgejo, vault, harbor, kanidm) + networking/edge, and runs **no** web workloads. Everything else moves to mini (or standby/), gated on a **file-based local-directory backup** that is restore-tested (Velero kept as untrusted offsite copy only). This is what frees the capacity the hub roles (D2/D5/D6, #1533/#1534/#1535/#1538) need on portable. One open call this raises for the hub: **where Sveltos lives** — see the comment on #1531.
Author
Owner

Update D5/D6: single-endpoint dual-auth and upgrades validated, no fork needed.

  • D5 single public endpoint per cluster with dual auth: validated via HTTPRoute 2-rule split (exchange HS256 -> TokenExchange, passthrough ES256/no auth -> apiserver OIDC). Single hostname mini/portable.k8s.animeteamspeak.moe serves both. No need for Option A/B/C. See #1534 comment for token-type regex details.
  • D6 WebSocket/SPDY: validated via backend.http.version HTTP1 (faa19b0c). H2 Extended CONNECT tracked in #1590 for future h2 regain.
  • Machine + human kubeconfigs both work against same URL (tested /tmp/testkubeconfig oidc-login and /tmp/kubeconfig-mini.yaml SA token). D5/D6 no longer gate #1533/#1528.
Update D5/D6: single-endpoint dual-auth and upgrades validated, no fork needed. - D5 single public endpoint per cluster with dual auth: validated via HTTPRoute 2-rule split (exchange HS256 -> TokenExchange, passthrough ES256/no auth -> apiserver OIDC). Single hostname mini/portable.k8s.animeteamspeak.moe serves both. No need for Option A/B/C. See #1534 comment for token-type regex details. - D6 WebSocket/SPDY: validated via backend.http.version HTTP1 (faa19b0c). H2 Extended CONNECT tracked in #1590 for future h2 regain. - Machine + human kubeconfigs both work against same URL (tested /tmp/testkubeconfig oidc-login and /tmp/kubeconfig-mini.yaml SA token). D5/D6 no longer gate #1533/#1528.
Author
Owner

Terminology correction (agentgateway → current architecture). The plan's "agentgateway as the single ingress for every cluster" is superseded. The live architecture is:

  • Edge ingress: Cilium Gateway API (gateway/cilium-default); haproxy is removed.
  • Apiserver access (k8s-hub): Cilium Gateway API + the custom authz-bridge (oauth.animeteamspeak.moe CRDs) doing the RFC 8693 exchange.
  • agentgateway: now AI-only (clusters/portable/ai/).

So throughout this plan, "agentgateway" (as the single ingress / apiserver proxy / token-exchange component) → Cilium Gateway API (edge) and k8s-hub + authz-bridge (apiservers). E.g. title "agentgateway ingress" → "Cilium Gateway API edge"; D3 "agentgateway trusts the shared CA for backendTLS" → the k8s-hub gateway/authz-bridge; D5 "agentgateway supports multiple auth configurations on a single endpoint / agentgateway exchange / passes it through" → the k8s-hub (Cilium + authz-bridge); D6 "exec/logs/port-forward through agentgateway" → through the k8s-hub; "Implement agentgateway as hub ingress (D5/D6) — #1538" → the Cilium edge / k8s-hub. (#1527, the edge research this fed, was closed as superseded by the Cilium Gateway API edge.)

**Terminology correction (agentgateway → current architecture).** The plan's "agentgateway as the single ingress for every cluster" is **superseded**. The live architecture is: - **Edge ingress:** Cilium Gateway API (`gateway/cilium-default`); haproxy is removed. - **Apiserver access (k8s-hub):** Cilium Gateway API + the custom **authz-bridge** (`oauth.animeteamspeak.moe` CRDs) doing the RFC 8693 exchange. - **agentgateway:** now AI-only (`clusters/portable/ai/`). So throughout this plan, "agentgateway" (as the single ingress / apiserver proxy / token-exchange component) → **Cilium Gateway API (edge)** and **k8s-hub + authz-bridge** (apiservers). E.g. title "agentgateway ingress" → "Cilium Gateway API edge"; D3 "agentgateway trusts the shared CA for backendTLS" → the k8s-hub gateway/authz-bridge; D5 "agentgateway supports multiple auth configurations on a single endpoint / agentgateway exchange / passes it through" → the k8s-hub (Cilium + authz-bridge); D6 "exec/logs/port-forward through agentgateway" → through the k8s-hub; "Implement agentgateway as hub ingress (D5/D6) — #1538" → the Cilium edge / k8s-hub. (#1527, the edge research this fed, was closed as superseded by the Cilium Gateway API edge.)
ginjiruu changed title from Plan: hub architecture — portable as hub, WireGuard mesh + agentgateway ingress + shared CA to Plan: hub architecture — portable as hub, WireGuard mesh + Cilium Gateway API edge + shared CA 2026-09-17 23:02:09 +00:00
Author
Owner

Closing as superseded: portable is gone, cross-site links are NetBird (lab/iac ADR-0008), certificates come from OpenBao (lab/iac ADR-0009), and every child ticket is closed.

Closing as superseded: portable is gone, cross-site links are NetBird (lab/iac ADR-0008), certificates come from OpenBao (lab/iac ADR-0009), and every child ticket is closed.
Author
Owner

Reopened: the user reviewed the triage on 2026-11-22 and keeps the hub plan. It isn't incompatible with NetBird (iac ADR-0008), and Sveltos is still planned. The superseded close was a parallel session acting on the unreviewed proposal.

Reopened: the user reviewed the triage on 2026-11-22 and keeps the hub plan. It isn't incompatible with NetBird (iac ADR-0008), and Sveltos is still planned. The superseded close was a parallel session acting on the unreviewed proposal.
ginjiruu reopened this issue 2026-11-22 21:38:59 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/clusters#1532
No description provided.