Implement Cilium ClusterMesh between portable and mini (Global Services) #1528

Open
opened 2026-08-13 19:29:39 +00:00 by ginjiruu · 2 comments
Owner

Implement Cilium ClusterMesh between portable and mini (Global Services)

Cross-cluster routing for the "single-pod app on a non-internet-connected cluster" problem from #1527, using the ClusterMesh feature all clusters already run Cilium for. Goal: agentgateway (edge, in portable) routes to mini apps as ordinary local Service backends, dropping haproxy's static per-SNI backend entries to 10.10.6.x.

Deployed Cilium state (current, cross-referenced)

mini portable
Cilium version 1.19.6 1.19.6
datapath routingMode: native routingMode: native
kubeProxyReplacement true true
encryption type: wireguard none
podCIDR (cluster-pool) 10.44.0.0/16 10.42.0.0/16
ipv4NativeRoutingCIDR 10.0.0.0/8 10.42.0.0/16
LB pool 10.10.6.0/24 10.10.5.0/24
BGP AS64516 → 10.15.1.1 AS64515 → 10.15.1.1
cluster.name / cluster.id not set not set

Both Cilium installs are HelmReleases pinned to 1.19.6 (mini via clusters/mini/cilium/ values; portable via inline clusters/portable/cilium/helmRelease.yaml). localhost (dev, gatewayAPI on) is out of scope for v1.

Prerequisites check (against docs.cilium.io cluster-mesh/setup)

  • Same datapath mode — native on both. ✅
  • Non-conflicting PodCIDRs — mini 10.44.0.0/16, portable 10.42.0.0/16. ✅ no overlap.
  • Node/pod connectivity between clusters — mini nodes 10.10.6.x, portable 10.10.5.x, both BGP-peered to 10.15.1.1 (lab-erx-01). L3 path exists via edge router; must be verified for pod IPs.
  • Native-routed datapath: ipv4NativeRoutingCIDR must cover all PodCIDRs across all mesh clusters. mini is /8 (covers both). portable is 10.42.0.0/16 — does NOT cover mini's 10.44.0.0/16. Portable must be widened to 10.0.0.0/8.
  • Encryption consistency — WireGuard enabled on mini only. ClusterMesh distributes WireGuard keys between clusters automatically, but all mesh clusters must run the same encryption mode (mixed is unsupported for inter-cluster traffic). Portable must enable encryption: {enabled: true, type: wireguard}. Firewall: UDP 51871 open between all mesh nodes.
  • maxConnectedClusters — default 255 is fine for 2 clusters; leave unset.

Changes to implement

  1. Set cluster.name / cluster.id on both HelmReleases (mini: e.g. cluster.name: mini, cluster.id: 1; portable: cluster.name: portable, cluster.id: 2). Changing these later requires restarting all workloads.
  2. Portable: add WireGuard encryption; widen ipv4NativeRoutingCIDR to 10.0.0.0/8.
  3. Enable clustermesh control plane on both (helm values):
    • clustermesh.enabled: true
    • clustermesh.apiserver.service.type: LoadBalancer (both clusters BGP-advertise LB VIPs: portable 10.10.5.x, mini 10.10.6.x; verified reachable cross-cluster via edge router)
    • wireguard node-to-node encryption so clustermesh-apiserver traffic is also encrypted.
  4. Connect: after both apiserver components are up, cilium clustermesh connect in one direction establishes both. Validate with cilium connectivity test --multi-cluster.
  5. Export the single-pod apps currently reached via haproxy SNI fan-out (mini.map → mini_kgateway, e.g. media, search, cloud, photos, ai, agentvault, supernote, etc.).

Load-balancing & service discovery choice

Docs (load-balancing/) offer two mechanisms:

  • Global Services — annotate identical-name/ns Services with service.cilium.io/global: "true". No CoreDNS dependency. Simplest for this repo's hand-managed Services. Recommended.
  • MCS-API — ServiceExport/ServiceImport, requires CoreDNS ≥ 1.12.2 (K8s 1.35+) with clusterset.local, or clustermesh.mcsapi.corednsAutoConfigure. Higher-level but more moving parts.

agentgateway does not support GEP-1748 (ServiceImport backendRef — documented as unsupported), so the route is: agentgateway → plain Service backend → Global Service whose remote endpoints Cilium merges in. Global Services create a real Service object in each cluster, so agentgateway needs no GEP-1748 support. If EndpointSlice-based third-party controllers were needed, clustermesh.enableEndpointSliceSynchronization (beta) is the fallback — not needed for the agentgateway path.

For the single-pod apps (one backend in mini), set service.cilium.io/affinity: "local" on the Service in mini (keeps mini's pods local-preferred) — or omit affinity for the default "any cluster" behavior.

Security policies (docs: policy/)

  • Cilium ≥ 1.18 selects local-cluster endpoints by default in policies; remote clusters must be targeted explicitly via io.cilium.k8s.policy.cluster: <name> (or a matchExpressions Exists for "any cluster"). Existing CiliumNetworkPolicy/NetworkPolicy must be audited once mesh is up or cross-cluster traffic may be silently blocked by default-deny.
  • Stale-backend guard: clustermesh.cacheTTL (default 0s = never revoke). Consider 15m so a down mini stops receiving traffic.

Relationship to haproxy retirement and #1527

After the mesh is up, haproxy's mini_kgateway_tcp backends (10.10.6.9:443) and mini.map fan-out can be replaced by agentgateway routing to the Global Services. haproxy itself stays as the internet-facing L4 edge until agentgateway's OIDC web login lands upstream (agentgateway/agentgateway#1450). This is the enabler for the "all in on agentgateway" end state.

Integration with existing work

  • #1527 (edge research) — this is the implementation of its option 1.
  • lab/iac#28 (kubeconfig distribution & connectivity) — ClusterMesh gives the same cross-cluster fabric that #28's reverse-tunnel path is solving for firewalled clusters; the mesh does NOT replace the tunnel for clusters that cannot hold BGP/LB connectivity, but complements it for portable↔mini.
  • #1522 (k8s-apiserver OIDC flags) — unrelated to mesh mechanics, but the mesh means an agentgateway in portable could reach the mini apiserver's token-exchange routes without new VIPs.

Acceptance criteria

  • cilium clustermesh status on both clusters shows all nodes connected
  • cilium connectivity test --multi-cluster passes
  • A single-pod mini app is reachable via a Global Service from a portable agentgateway route, with no haproxy mini_* SNI entry
  • WireGuard encryption active for inter-cluster pod traffic (portable + mini)
  • Cross-cluster network policies audited/targeted explicitly

Blocked by

  • #1527 (research decisions, option 1 validated)
  • agentgateway OIDC web login upstream (agentgateway/agentgateway#1450) only for the full haproxy retirement — not required for the mesh itself

Follow-up question (captured for later)

Egress Gateway is documented as not compatible with Cluster Mesh — the egress gateway node must be in the same cluster as the selected pods, and the two features cannot be combined. Keep egress policies per-cluster or route external-destined traffic through a central gateway outside the fabric. See egress-gateway docs.

## Implement Cilium ClusterMesh between portable and mini (Global Services) Cross-cluster routing for the "single-pod app on a non-internet-connected cluster" problem from #1527, using the ClusterMesh feature all clusters already run Cilium for. Goal: agentgateway (edge, in portable) routes to mini apps as ordinary local Service backends, dropping haproxy's static per-SNI backend entries to `10.10.6.x`. ## Deployed Cilium state (current, cross-referenced) | | mini | portable | |---|---|---| | Cilium version | 1.19.6 | 1.19.6 | | datapath | `routingMode: native` | `routingMode: native` | | kubeProxyReplacement | true | true | | encryption | `type: wireguard` | **none** | | podCIDR (cluster-pool) | `10.44.0.0/16` | `10.42.0.0/16` | | ipv4NativeRoutingCIDR | `10.0.0.0/8` | `10.42.0.0/16` | | LB pool | `10.10.6.0/24` | `10.10.5.0/24` | | BGP | AS64516 → 10.15.1.1 | AS64515 → 10.15.1.1 | | cluster.name / cluster.id | **not set** | **not set** | Both Cilium installs are HelmReleases pinned to `1.19.6` (mini via `clusters/mini/cilium/` values; portable via inline `clusters/portable/cilium/helmRelease.yaml`). `localhost` (dev, gatewayAPI on) is out of scope for v1. ## Prerequisites check (against docs.cilium.io cluster-mesh/setup) - **Same datapath mode** — native on both. ✅ - **Non-conflicting PodCIDRs** — mini `10.44.0.0/16`, portable `10.42.0.0/16`. ✅ no overlap. - **Node/pod connectivity between clusters** — mini nodes `10.10.6.x`, portable `10.10.5.x`, both BGP-peered to `10.15.1.1` (lab-erx-01). L3 path exists via edge router; must be verified for pod IPs. - **Native-routed datapath: `ipv4NativeRoutingCIDR` must cover all PodCIDRs across all mesh clusters.** mini is `/8` (covers both). **portable is `10.42.0.0/16` — does NOT cover mini's `10.44.0.0/16`. Portable must be widened to `10.0.0.0/8`.** - **Encryption consistency** — WireGuard enabled on mini only. ClusterMesh distributes WireGuard keys between clusters automatically, but **all mesh clusters must run the same encryption mode** (mixed is unsupported for inter-cluster traffic). Portable must enable `encryption: {enabled: true, type: wireguard}`. Firewall: UDP `51871` open between all mesh nodes. - **`maxConnectedClusters`** — default 255 is fine for 2 clusters; leave unset. ## Changes to implement 1. **Set `cluster.name` / `cluster.id`** on both HelmReleases (mini: e.g. `cluster.name: mini`, `cluster.id: 1`; portable: `cluster.name: portable`, `cluster.id: 2`). Changing these later requires restarting all workloads. 2. **Portable**: add WireGuard encryption; widen `ipv4NativeRoutingCIDR` to `10.0.0.0/8`. 3. **Enable clustermesh control plane on both** (helm values): - `clustermesh.enabled: true` - `clustermesh.apiserver.service.type: LoadBalancer` (both clusters BGP-advertise LB VIPs: portable `10.10.5.x`, mini `10.10.6.x`; verified reachable cross-cluster via edge router) - wireguard node-to-node encryption so clustermesh-apiserver traffic is also encrypted. 4. **Connect**: after both apiserver components are up, `cilium clustermesh connect` in one direction establishes both. Validate with `cilium connectivity test --multi-cluster`. 5. **Export the single-pod apps** currently reached via haproxy SNI fan-out (mini.map → `mini_kgateway`, e.g. media, search, cloud, photos, ai, agentvault, supernote, etc.). ## Load-balancing & service discovery choice Docs (load-balancing/) offer two mechanisms: - **Global Services** — annotate identical-name/ns Services with `service.cilium.io/global: "true"`. No CoreDNS dependency. Simplest for this repo's hand-managed Services. **Recommended.** - **MCS-API** — `ServiceExport`/`ServiceImport`, requires CoreDNS ≥ 1.12.2 (K8s 1.35+) with `clusterset.local`, or `clustermesh.mcsapi.corednsAutoConfigure`. Higher-level but more moving parts. agentgateway does **not** support GEP-1748 (ServiceImport backendRef — documented as unsupported), so the route is: agentgateway → plain `Service` backend → Global Service whose remote endpoints Cilium merges in. Global Services create a real Service object in each cluster, so agentgateway needs no GEP-1748 support. If EndpointSlice-based third-party controllers were needed, `clustermesh.enableEndpointSliceSynchronization` (beta) is the fallback — not needed for the agentgateway path. For the single-pod apps (one backend in mini), set `service.cilium.io/affinity: "local"` on the Service in mini (keeps mini's pods local-preferred) — or omit affinity for the default "any cluster" behavior. ## Security policies (docs: policy/) - Cilium ≥ 1.18 selects local-cluster endpoints by default in policies; remote clusters must be targeted explicitly via `io.cilium.k8s.policy.cluster: <name>` (or a `matchExpressions` `Exists` for "any cluster"). Existing `CiliumNetworkPolicy`/`NetworkPolicy` must be audited once mesh is up or cross-cluster traffic may be silently blocked by default-deny. - Stale-backend guard: `clustermesh.cacheTTL` (default `0s` = never revoke). Consider `15m` so a down mini stops receiving traffic. ## Relationship to haproxy retirement and #1527 After the mesh is up, haproxy's `mini_kgateway_tcp` backends (10.10.6.9:443) and `mini.map` fan-out can be replaced by agentgateway routing to the Global Services. haproxy itself stays as the internet-facing L4 edge until agentgateway's OIDC web login lands upstream (agentgateway/agentgateway#1450). This is the enabler for the "all in on agentgateway" end state. ## Integration with existing work - **#1527** (edge research) — this is the implementation of its option 1. - **lab/iac#28** (kubeconfig distribution & connectivity) — ClusterMesh gives the same cross-cluster fabric that #28's reverse-tunnel path is solving for firewalled clusters; the mesh does NOT replace the tunnel for clusters that cannot hold BGP/LB connectivity, but complements it for portable↔mini. - **#1522** (k8s-apiserver OIDC flags) — unrelated to mesh mechanics, but the mesh means an agentgateway in portable could reach the mini apiserver's token-exchange routes without new VIPs. ## Acceptance criteria - [ ] `cilium clustermesh status` on both clusters shows all nodes connected - [ ] `cilium connectivity test --multi-cluster` passes - [ ] A single-pod mini app is reachable via a Global Service from a portable agentgateway route, with no haproxy `mini_*` SNI entry - [ ] WireGuard encryption active for inter-cluster pod traffic (portable + mini) - [ ] Cross-cluster network policies audited/targeted explicitly ## Blocked by - #1527 (research decisions, option 1 validated) - agentgateway OIDC web login upstream (agentgateway/agentgateway#1450) only for the *full* haproxy retirement — not required for the mesh itself ## Follow-up question (captured for later) Egress Gateway is documented as **not compatible with Cluster Mesh** — the egress gateway node must be in the same cluster as the selected pods, and the two features cannot be combined. Keep egress policies per-cluster or route external-destined traffic through a central gateway outside the fabric. See egress-gateway docs.
Author
Owner

Terminology correction (agentgateway → current architecture). The edge is no longer agentgateway — it's Cilium Gateway API (gateway/cilium-default), and haproxy is already removed. agentgateway is now AI-only.

So in this ticket:

  • "agentgateway (edge, in portable) routes to mini apps as ordinary local Service backends" → "the Cilium gateway (edge, in portable)."
  • "agentgateway does not support GEP-1748… so the route is: agentgateway → plain Service backend → Global Service" → re-evaluate this for Cilium's Gateway API implementation (Cilium may support MCS-API/ServiceImport; needs a fresh check) rather than agentgateway's.
  • "haproxy itself stays as the internet-facing L4 edge until agentgateway's OIDC web login lands upstream (agentgateway#1450). This is the enabler for the 'all in on agentgateway' end state." → factually stale: haproxy is gone and the edge is Cilium; the "all in on agentgateway" end state is superseded. The ClusterMesh goal itself (route the edge → Global Services instead of the current per-hostname static-IP passthrough) is still valid and forward-looking.
**Terminology correction (agentgateway → current architecture).** The edge is no longer agentgateway — it's **Cilium Gateway API** (`gateway/cilium-default`), and haproxy is already removed. agentgateway is now AI-only. So in this ticket: - "agentgateway (edge, in portable) routes to mini apps as ordinary local Service backends" → "the **Cilium** gateway (edge, in portable)." - "agentgateway does not support GEP-1748… so the route is: agentgateway → plain Service backend → Global Service" → re-evaluate this for **Cilium's** Gateway API implementation (Cilium may support MCS-API/ServiceImport; needs a fresh check) rather than agentgateway's. - "haproxy itself stays as the internet-facing L4 edge until agentgateway's OIDC web login lands upstream (agentgateway#1450). This is the enabler for the 'all in on agentgateway' end state." → **factually stale**: haproxy is gone and the edge is Cilium; the "all in on agentgateway" end state is superseded. The ClusterMesh goal itself (route the edge → Global Services instead of the current per-hostname static-IP passthrough) is still valid and forward-looking.
Author
Owner

Now tracked under lab/clusters#1668. Portable is the think cluster. Before enabling ClusterMesh both clusters need unique Cilium cluster-name/cluster-id (both are default/0 today); think gets them at its planned rebuild (lab/machine-configs, see lab/machine-configs#7).

Now tracked under lab/clusters#1668. Portable is the think cluster. Before enabling ClusterMesh both clusters need unique Cilium `cluster-name`/`cluster-id` (both are `default`/0 today); think gets them at its planned rebuild (lab/machine-configs, see lab/machine-configs#7).
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#1528
No description provided.