Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions api/v1alpha1/masque_listener_bundle_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2026 Datum Cloud, Inc.
//
// SPDX-License-Identifier: AGPL-3.0-or-later

package v1alpha1_test

import (
"context"
"os"
"path/filepath"
"strings"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

galacticv1alpha1 "go.datum.net/galactic/api/v1alpha1"
)

// TestMASQUEPublicListenerBundle creates the EdgeService and EdgeListener
// that config/masque/provider/components/public-listener ships, so the
// bundle's placeholders stay valid against the CRDs an overlay patches.
func TestMASQUEPublicListenerBundle(t *testing.T) {
c, dyn := startAPIServer(t)
ctx := context.Background()
dir := filepath.Join("..", "..", "config", "masque", "provider", "components", "public-listener")

ns := &unstructured.Unstructured{Object: map[string]any{
"apiVersion": "v1", "kind": "Namespace", "metadata": map[string]any{"name": "galactic-system"},
}}
if _, err := dyn.Resource(schema.GroupVersionResource{Version: "v1", Resource: "namespaces"}).
Create(ctx, ns, metav1.CreateOptions{}); err != nil {
t.Fatal(err)
}
for _, f := range []struct {
file string
obj func() client.Object
}{
{"trafficpolicy.yaml", func() client.Object { return &galacticv1alpha1.TrafficPolicy{} }},
{"edgeservice.yaml", func() client.Object { return &galacticv1alpha1.EdgeService{} }},
{"edgelistener.yaml", func() client.Object { return &galacticv1alpha1.EdgeListener{} }},
} {
b, err := os.ReadFile(filepath.Join(dir, f.file))
if err != nil {
t.Fatal(err)
}
for i, doc := range strings.Split(string(b), "\n---\n") {
obj := f.obj()
if err := yaml.UnmarshalStrict([]byte(doc), obj); err != nil {
t.Fatalf("%s document %d: %v", f.file, i, err)
}
if err := c.Create(ctx, obj); err != nil {
t.Fatalf("%s document %d is not admitted: %v", f.file, i, err)
}
}
}
}
7 changes: 7 additions & 0 deletions config/masque/edgeprovider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ metadata:
spec:
contractVersions:
- v1alpha1
# PacketAccess and PrefixReachability serve connectors. SocketAccess and
# PublicListener serve the provider's public listener, whose EdgeService
# provider/components/public-listener adds.
capabilities:
- name: PacketAccess
version: v1
- name: PrefixReachability
version: v1
- name: SocketAccess
version: v1
- name: PublicListener
version: v1
serviceAccounts:
- namespace: masque-system
name: masque-provider
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# CONNECT-IP over HTTP/3 on UDP/443 and over HTTP/2 on TCP/443, both to the
# provider's port 8443. The addresses are documentation placeholders: an
# overlay sets one IPv6 and one IPv4 address from the cell's gateway VIP
# prefixes (galactic-controller --edge-listener-vip-prefixes). The gateway
# health check probes TCP 8443 on each listener attachment.
apiVersion: galactic.datumapis.com/v1alpha1
kind: EdgeListener
metadata:
name: masque-public
namespace: galactic-system
spec:
providerRef:
name: masque
serviceRef:
namespace: galactic-system
name: masque-ingress
addresses:
- 2001:db8::443
- 192.0.2.43
ports:
- protocol: udp
port: 443
backendPort: 8443
- protocol: tcp
port: 443
backendPort: 8443
sessionAffinity: ClientIPAndProtocol
failurePolicy: FailClosed
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Grants the masque provider's listener attachments in its ingress gVPC.
# vpcRef.uid and clientPool are placeholders an overlay must replace before
# the first apply: both are immutable once the object exists, so an
# EdgeService created with the placeholders has to be deleted and created
# again. Read them from the ingress gVPC, which galactic-controller creates
# without this component, with
# kubectl -n galactic-system get vpc edge-ingress-masque \
# -o jsonpath='{.metadata.uid} {.spec.networks[0]}'
# The pool may be the gVPC's whole /64. trafficpolicy.yaml holds the
# policies it binds.
apiVersion: galactic.datumapis.com/v1alpha1
kind: EdgeService
metadata:
name: masque-ingress
namespace: galactic-system
spec:
providerRef:
name: masque
vpcRef:
name: edge-ingress-masque
uid: 00000000-0000-0000-0000-000000000000
capabilities:
- SocketAccess
- PublicListener
clientPool: fd00:ffff::/64
trafficPolicy:
ingressPolicyRef:
name: masque-listener-ingress
egressPolicyRef:
name: masque-listener-egress
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Serve the provider through the cell's public listener (PublicListener/v1,
# docs/designs/edge-public-listener.md) instead of a Service. Include it from
# the overlay of config/masque/provider:
#
# resources:
# - ../../config/masque/provider
# components:
# - ../../config/masque/provider/components/public-listener
#
# It adds the ingress gVPC's EdgeService and its traffic policies, the
# EdgeListener that serves it on the cell's gateway VIPs and the provider's
# read access to that EdgeService, and starts the provider with
# --listener-service. Before the first apply the overlay replaces the
# per-cell placeholders: the EdgeService's vpcRef.uid and clientPool, read
# from the edge-ingress-masque VPC that galactic-controller creates once
# --edge-ingress-identity names masque, and the EdgeListener's addresses
# (docs/edge/masque-service.md).
#
# The objects name their namespaces, galactic-system and masque-system, and
# reference each other by them. An overlay that sets namespace: rewrites
# them and breaks those references.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- trafficpolicy.yaml
- edgeservice.yaml
- edgelistener.yaml
- rbac.yaml
patches:
# The pod serves on its listener attachment, not the pod network, and
# keeps serving for 5 seconds after it stops taking new flows, so its
# shutdown needs up to 30 seconds after SIGTERM.
- target:
kind: Deployment
name: masque-provider
patch: |-
- op: add
path: /spec/template/spec/containers/0/args/-
value: --listener-service=galactic-system/masque-ingress
- op: replace
path: /spec/template/spec/terminationGracePeriodSeconds
value: 40
27 changes: 27 additions & 0 deletions config/masque/provider/components/public-listener/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# masque-provider reads the one EdgeService its --listener-service names,
# for the UID its listener attachment pins. An overlay that renames the
# EdgeService renames it here too.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: masque-provider-listener
namespace: galactic-system
rules:
- apiGroups: [galactic.datumapis.com]
resources: [edgeservices]
resourceNames: [masque-ingress]
verbs: [get]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: masque-provider-listener
namespace: galactic-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: masque-provider-listener
subjects:
- kind: ServiceAccount
name: masque-provider
namespace: masque-system
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# The listener attachments receive the gateways' public listener traffic and
# answer it, and the TCP health probes their own node sends to the backend
# port from its host-side link-local address, and nothing else. Without a
# policy an EdgeService denies everything in that direction.
apiVersion: galactic.datumapis.com/v1alpha1
kind: TrafficPolicy
metadata:
name: masque-listener-ingress
namespace: galactic-system
spec:
rules:
- name: allow-listener
action: Allow
match:
path: PublicService
- name: allow-health-probe
action: Allow
match:
path: Private
protocol: TCP
sourceCIDRs: ["fe80::/10"]
destinationPorts: [{start: 8443, end: 8443}]
---
apiVersion: galactic.datumapis.com/v1alpha1
kind: TrafficPolicy
metadata:
name: masque-listener-egress
namespace: galactic-system
spec:
rules:
- name: allow-listener-replies
action: Allow
match:
path: PublicService
- name: allow-health-probe-replies
action: Allow
match:
path: Private
protocol: TCP
destinationCIDRs: ["fe80::/10"]
sourcePorts: [{start: 8443, end: 8443}]
7 changes: 4 additions & 3 deletions config/masque/provider/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# applied as-is. An overlay appends --authority with the name clients use,
# supplies the masque-provider-tls Secret (tls.crt, tls.key) for that name
# and the masque-authority-ca ConfigMap (ca.crt) the grant authority's
# certificate chains to, and chooses how the masque-provider Service is
# exposed. It may also set the TUN device plugin's resource name.
# certificate chains to, and chooses how clients reach the pods: through
# the cell's public listener with components/public-listener, or through
# a Service of its own. The bundle ships no Service. It may also set the
# TUN device plugin's resource name.
#
# With the authority's components/cert-manager, include components/cert-manager
# here to trust the CA that issued it. A CA published under another name is
# swapped in by patching the authority-ca volume's sources by name
# (docs/edge/masque-service.md).
resources:
- deployment.yaml
- service.yaml
24 changes: 0 additions & 24 deletions config/masque/provider/service.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# (../authority/kustomization.yaml). The base's TUN resource,
# devic.es/tun, is the one the device plugin serves
# (config/galactic-edge/tun-device-plugin), so it is kept. Clients reach the
# pod directly from its node, so the Service stays ClusterIP.
# pod directly from its node, so it needs no Service or public listener.
#
# The edge nodes cannot reach the cluster DNS, so the pod resolves the
# authority's name through a host alias to the fixed address of its Service
Expand Down
7 changes: 4 additions & 3 deletions docs/designs/edge-public-listener.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Galactic Edge public listener

Status: proposed, with its open decisions settled. The Phase 0 lab proof is done (see [Phase 0 results](#phase-0-results)), and Phase 1, the API, is implemented: `EdgeListener`, the `PublicListener` capability and `NetworkService.spec.edgeListenerRef` exist. Phase 2, core, is implemented: the ingress gVPC, listener admission and status, `/128` publication and the `NetworkService` writer. Phase 3's unmatched-egress drop is implemented. Gateways deliver to a backend on their own node (#1526), so the local-delivery exclusion applies only to a gateway that cannot. Phase 4's backend resolution is implemented: gateways and `galactic-router` serve a listener from the backends core reports serving. Its lab failover tests are not done yet. It extends the [Galactic Edge Foundation](galactic-edge.md) and reuses the [XDP/DSR gateway](../gateway/architecture.md). The [provider contract](../edge/provider-contract.md) remains the reference for behavior that exists today.
Status: proposed, with its open decisions settled. The Phase 0 lab proof is done (see [Phase 0 results](#phase-0-results)), and Phase 1, the API, is implemented: `EdgeListener`, the `PublicListener` capability and `NetworkService.spec.edgeListenerRef` exist. Phase 2, core, is implemented: the ingress gVPC, listener admission and status, `/128` publication and the `NetworkService` writer. Phase 3's unmatched-egress drop is implemented. Gateways deliver to a backend on their own node (#1526), so the local-delivery exclusion applies only to a gateway that cannot. Phase 4's backend resolution is implemented: gateways and `galactic-router` serve a listener from the backends core reports serving. Its lab failover tests are not done yet. Phase 5's provider and bundle changes are implemented: `masque-provider --listener-service` serves from a listener attachment, and `config/masque/provider/components/public-listener` replaces the Service. Its lab acceptance tests are not done yet. It extends the [Galactic Edge Foundation](galactic-edge.md) and reuses the [XDP/DSR gateway](../gateway/architecture.md). The [provider contract](../edge/provider-contract.md) remains the reference for behavior that exists today.

This design follows the [Datum enhancement template](https://github.com/datum-cloud/enhancements/blob/main/enhancements/template/README.md).

Expand Down Expand Up @@ -142,8 +142,8 @@ spec:
- 2001:db8:100::10
- 192.0.2.10
ports:
- {name: h3, protocol: UDP, port: 443, backendPort: 8443}
- {name: h2, protocol: TCP, port: 443, backendPort: 8443}
- {protocol: udp, port: 443, backendPort: 8443}
- {protocol: tcp, port: 443, backendPort: 8443}
healthPort: 8443 # TCP backend port probed for health; defaults to the first TCP backendPort, required when every port is UDP
sessionAffinity: ClientIPAndProtocol # defaults to ClientIPAndProtocol
failurePolicy: FailClosed # copied into each NetworkService's healthCheck
Expand Down Expand Up @@ -305,6 +305,7 @@ Each listener has up to 16 ports and two addresses, and each port is one `Networ
- 2026-11-28: Phase 0 proved remote delivery and the reply path, and showed local delivery failing ([#1507](https://github.com/datum-cloud/galactic/issues/1507)).
- 2026-11-28: Phase 2 core controllers implemented ([#1509](https://github.com/datum-cloud/galactic/issues/1509)).
- 2026-11-28: Phase 3 added the unmatched-egress drop on listener host links ([#1510](https://github.com/datum-cloud/galactic/issues/1510)).
- 2026-11-30: Phase 5 served MASQUE from listener attachments and replaced its Service with the public listener ([#1512](https://github.com/datum-cloud/galactic/issues/1512)).

## Drawbacks

Expand Down
2 changes: 1 addition & 1 deletion docs/edge/masque-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The adapter never touches host networking. galactic-edge programs and releases e

The cell must run galactic-controller with `--edge` and the galactic-edge DaemonSet on the provider's node ([deployment](provider-contract.md)). The provider's node also needs a TUN device plugin (`config/galactic-edge/tun-device-plugin`). The VPC needs no workload on that node: galactic-edge creates the VPC's host VRF there when the attachment is its only user.

1. Register the provider: an `EdgeProvider` that lists contract version `v1alpha1`, `PacketAccess/v1` and `PrefixReachability/v1`, and names the provider's ServiceAccount. An operator approves it with an `EdgeProviderApproval` of the same name (`config/masque/approval`). galactic-controller then binds the provider role and admission policy to that ServiceAccount.
1. Register the provider: an `EdgeProvider` that lists contract version `v1alpha1`, `PacketAccess/v1` and `PrefixReachability/v1` for connectors, `SocketAccess/v1` and `PublicListener/v1` for its [public listener](masque-service.md#public-listener), and names the provider's ServiceAccount. An operator approves it with an `EdgeProviderApproval` of the same name (`config/masque/approval`). galactic-controller then binds the provider role and admission policy to that ServiceAccount.
2. Grant each connector an `EdgeService` in its VPC's namespace. The [grant authority](masque-authority.md) issues one per connector authorization. It grants `PacketAccess` and `PrefixReachability`, lists the connector's /96 in `prefixes`, and sets a `clientPool` outside every connector /96. A service that lacks `PrefixReachability` gets an attachment, but core refuses every route on it.
3. Run the provider pod as that ServiceAccount, with a pod-bound token, the downward-API pod name, namespace, UID and node name, a device-plugin TUN, and no host namespace, hostPath, `NET_ADMIN` or BPF access. `tests/edgeconformance/masqueprovider/deploy/` is a worked example.

Expand Down
Loading
Loading