Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
migrate from hub to control plane
Antonio Ojea507418146126
diff --git a/.github/k8s/sam-hub-template.yaml b/.github/k8s/sam-hub-template.yamldeleted file mode 100644index 8ed117af..00000000--- a/.github/k8s/sam-hub-template.yaml+++ /dev/null@@ -1,206 +0,0 @@-apiVersion: v1-kind: Service-metadata:- name: sam-hub-${ENV_NAME}- namespace: ${NAMESPACE}-spec:- clusterIP: None- ports:- - port: 9090- targetPort: 9090- protocol: TCP- name: http- - port: 4501- targetPort: 4501- protocol: TCP- name: p2p-tcp- - port: 4501- targetPort: 4501- protocol: UDP- name: p2p-udp- selector:- app: sam-hub-${ENV_NAME}-----apiVersion: apps/v1-kind: StatefulSet-metadata:- name: sam-hub-${ENV_NAME}- namespace: ${NAMESPACE}-spec:- serviceName: "sam-hub-${ENV_NAME}"- replicas: 3- selector:- matchLabels:- app: sam-hub-${ENV_NAME}- template:- metadata:- labels:- app: sam-hub-${ENV_NAME}- spec:- containers:- - name: sam-hub- image: ghcr.io/google/sam-hub:${IMAGE_TAG}- env:- - name: HOST_IP- valueFrom:- fieldRef:- fieldPath: status.hostIP- - name: SAM_HUB_KEY- valueFrom:- secretKeyRef:- name: sam-hub-secret- key: sam-hub-key- optional: true # Make it optional so it doesn't block local kind testing if not created- ports:- - containerPort: 9090- protocol: TCP- name: metrics- - containerPort: 4501- hostPort: 4501- protocol: TCP- name: p2p-tcp- - containerPort: 4501- hostPort: 4501- protocol: UDP- name: p2p-udp- readinessProbe:- httpGet:- path: /healthz- port: metrics- scheme: HTTP- initialDelaySeconds: 5- periodSeconds: 10- livenessProbe:- httpGet:- path: /healthz- port: metrics- scheme: HTTP- initialDelaySeconds: 15- periodSeconds: 20- args:- - "--listen=/ip4/0.0.0.0/tcp/4501"- - "--listen=/ip4/0.0.0.0/udp/4501/quic-v1"- - "--external-multiaddr=/dnsaddr/bootstrap.${ENV_NAME}.sam-mesh.dev"- # 1. Trust Dex for humans/Google/GitHub. 2. Trust GKE for internal Canaries.- - "--issuer=https://auth.sam-mesh.dev,https://container.googleapis.com/v1/projects/${GCP_PROJECT_ID}/locations/${CLUSTER_REGION}/clusters/${CLUSTER_NAME}"- # 1. Dex CLI client ID. 2. Canary projected volume audience.- - "--allowed-audiences=sam-mesh-audience,sam-hub-audience"- - "--policy-file=/etc/sam/policies/policies.yaml"- resources:- requests:- cpu: 100m- memory: 128Mi- limits:- cpu: 500m- memory: 512Mi- volumeMounts:- - name: policies-volume- mountPath: /etc/sam/policies- readOnly: true- volumes:- - name: policies-volume- configMap:- name: sam-hub-policies-${ENV_NAME}-----apiVersion: v1-kind: ConfigMap-metadata:- name: sam-hub-policies-${ENV_NAME}- namespace: ${NAMESPACE}-data:- policies.yaml: |- version: "v1alpha1"- bindings:- - members: ["user:system:serviceaccount:sam-canary-${ENV_NAME}:sam-node-sa"]- role: "sam-canary"- - members: ["system:authenticated"]- role: "public-mesh"- roles:- sam-canary:- allowed_services:- - "*"- allowed_targets:- - "*"- public-mesh:- allowed_services:- - "*"- allowed_targets:- - "*"-----apiVersion: monitoring.googleapis.com/v1-kind: PodMonitoring-metadata:- name: sam-hub-monitor-${ENV_NAME}- namespace: ${NAMESPACE}-spec:- selector:- matchLabels:- app: sam-hub-${ENV_NAME}- endpoints:- - port: metrics- interval: 30s- path: /metrics- scheme: http-----apiVersion: networking.gke.io/v1-kind: HealthCheckPolicy-metadata:- name: sam-hub-healthcheck-${ENV_NAME}- namespace: ${NAMESPACE}-spec:- default:- checkIntervalSec: 15- timeoutSec: 5- healthyThreshold: 1- unhealthyThreshold: 2- config:- type: HTTP- httpHealthCheck:- requestPath: /healthz- targetRef:- group: ""- kind: Service- name: sam-hub-${ENV_NAME}-----apiVersion: gateway.networking.k8s.io/v1-kind: Gateway-metadata:- name: sam-hub-gateway-${ENV_NAME}- namespace: ${NAMESPACE}- annotations:- networking.gke.io/certmap: sam-hub-cert-map-${ENV_NAME}-spec:- gatewayClassName: gke-l7-global-external-managed- addresses:- - type: NamedAddress- value: sam-hub-ip-${ENV_NAME}- listeners:- - name: https- protocol: HTTPS- port: 443- allowedRoutes:- namespaces:- from: Same-----apiVersion: gateway.networking.k8s.io/v1-kind: HTTPRoute-metadata:- name: sam-hub-route-${ENV_NAME}- namespace: ${NAMESPACE}-spec:- parentRefs:- - name: sam-hub-gateway-${ENV_NAME}- hostnames:- - "${ENV_NAME}.sam-mesh.dev"- rules:- - matches:- - path:- type: Exact- value: /register- - path:- type: Exact- value: /info- backendRefs:- - name: sam-hub-${ENV_NAME}- port: 9090-diff --git a/site/content/docs/_index.md b/site/content/docs/_index.mdindex 9d7528c6..56b2a8ea 100644--- a/site/content/docs/_index.md+++ b/site/content/docs/_index.md@@ -11,7 +11,7 @@ Instead of exposing your agent's tools (like local scripts, LLM endpoints, or in**Security & Trust Boundaries (Read This First!)*** **Isolated by Default:** You do NOT join any mesh by default. You must explicitly configure the control plane (Hub) you want to join.* **Closed by Default:** Joining a mesh does not expose your tools. By default, your node does not allow any services to be reached by others. You must explicitly configure policies to share tools.-* **Bring Your Own Control Plane (DIY):** While we offer public testnets, the core design allows you to host your own `sam-hub` control plane. You retain 100% control over your data, identities, and authorization policies.+* **Bring Your Own Control Plane (DIY):** While we offer public testnets, the core design allows you to host your own SAM control plane. You retain 100% control over your data, identities, and authorization policies.---@@ -33,5 +33,6 @@ Compile from source, run local clusters, host your own control plane, or execute## Architecture-* **`sam-hub`**: The control plane for identity mapping, token issuing, and policy distribution.+* **`sam-control-plane`**: The control plane for identity mapping, token issuing, and policy distribution.+* **`sam-router`**: The GossipSub routing overlays and bootstrap points for the P2P mesh.* **`sam-node`**: The P2P nodes providing the mesh transport layer, self-healing connectivity, and local Model Context Protocol (MCP) HTTP interfaces.diff --git a/site/content/docs/development/_index.md b/site/content/docs/development/_index.mdindex b119d8f3..58a35df5 100644--- a/site/content/docs/development/_index.md+++ b/site/content/docs/development/_index.md@@ -29,24 +29,32 @@ make buildThis compiles and generates the following binaries under `./bin/`:-- `./bin/sam-hub`: The OIDC identity bridge and cryptographic Biscuit token issuer.+- `./bin/sam-control-plane`: The OIDC identity bridge and cryptographic Biscuit token issuer.+- `./bin/sam-router`: The GossipSub routing overlays and bootstrap points for the P2P mesh.- `./bin/sam-node`: The mesh agent node CLI supporting `join` and `run` commands.- `./bin/mcp-client`: A CLI-based utility to interact with MCP servers.----## Running a Local Dev Hub+## Running a Local Dev Control Plane and Router-To run `sam-hub` locally for testing, you must supply OIDC issuer configurations and a 32-byte hexadecimal seed key:+To run the control plane and router locally for testing:+1. **Start the Control Plane**:```bash-# Generate a random 32-byte key for biscuit signing-export SAM_HUB_KEY=$(openssl rand -hex 32)export SAM_OIDC_ISSUER=https://issuer.example.comexport SAM_OIDC_ID=sam-clientexport SAM_OIDC_SECRET=sam-secret-./bin/sam-hub+./bin/sam-control-plane --issuer=$SAM_OIDC_ISSUER --allowed-audiences=sam-mesh-audience+```++2. **Start the Router**:+```bash+./bin/sam-router \+ --control-plane=http://localhost:8080 \+ --listen=/ip4/127.0.0.1/tcp/4501 \+ --api-token=devtoken```---@@ -62,13 +70,13 @@ make test```### 2. Local E2E Tests (BATS)-Validates local command-line behaviors for `sam-node` and `sam-hub`:+Validates local command-line behaviors for `sam-node`, `sam-control-plane`, and `sam-router`:```bashmake test-e2e```### 3. Containerized Mesh E2E (BATS)-Builds local Docker images, spins up a mock OIDC server, runs `sam-hub` and multiple `sam-node` containers in a local bridge network, and performs end-to-end device flows and tool discovery:+Builds local Docker images, spins up a mock OIDC server, runs control-plane, router, and multiple `sam-node` containers in a local bridge network, and performs end-to-end device flows and tool discovery:```bashmake test-e2e-container```@@ -80,10 +88,10 @@ make test-e2e-containerFor end-to-end integration testing in a local Kubernetes environment, the repository provides `make` targets that stand up a complete mesh in `kind` with a single command:```bash-make kind-up # create the sam-kind cluster, build+load images, deploy hub + nodes+make kind-up # create the sam-kind cluster, build+load images, deploy control-plane + router + nodesmake kind-local-node # enroll a locally-built ./bin/sam-node into the meshmake kind-e2e-mesh # run the end-to-end discover-and-call checkmake kind-down # tear the cluster down```-`make kind-up` builds the `sam-hub:local` and `sam-node:local` images, creates a `sam-kind` cluster, and deploys the hub plus the nodes declared in `development/kind/mesh-config.yaml`. See the [Kubernetes Deployment and Local Testing Guide](kubernetes-deployment/#1-local-testing-with-kind) for details.+`make kind-up` builds the `sam-control-plane:local`, `sam-router:local`, and `sam-node:local` images, creates a `sam-kind` cluster, and deploys the control-plane and router plus the nodes declared in `development/kind/mesh-config.yaml`. See the [Kubernetes Deployment and Local Testing Guide](kubernetes-deployment/#1-local-testing-with-kind) for details.diff --git a/site/content/docs/development/kubernetes-deployment.md b/site/content/docs/development/kubernetes-deployment.mdindex 885c3322..0f531fdc 100644--- a/site/content/docs/development/kubernetes-deployment.md+++ b/site/content/docs/development/kubernetes-deployment.md@@ -2,7 +2,7 @@title: "Kubernetes Deployment and Local Testing Guide"linkTitle: "Kubernetes Deployment and Local Testing Guide"----This guide explains how to deploy the `sam-hub` in a Kubernetes cluster and how to test it locally with `kind` — using the bundled `make kind-*` targets for a one-command mesh, or a manual setup with `cloud-provider-kind`.+This guide explains how to deploy the SAM control plane and router in a Kubernetes cluster and how to test it locally with `kind` — using the bundled `make kind-*` targets for a one-command mesh, or a manual setup with `cloud-provider-kind`.> [!TIP]> This guide focuses on local development sandboxing. For production-grade Kubernetes deployments (GKE, EKS, AKS), see the [Production Kubernetes Deployment](../../user/kubernetes-deployment/) guide.@@ -19,9 +19,9 @@ The repository ships a one-command local mesh under `development/kind/`, drivenmake kind-up```-This creates a `sam-kind` cluster (one control-plane plus workers for the hub and `node-a`, `node-b`, `node-c`), builds the `sam-hub:local` and `sam-node:local` images, loads them into the cluster, and deploys:+This creates a `sam-kind` cluster (one control-plane plus workers for the control plane, router, and `node-a`, `node-b`, `node-c`), builds the `sam-control-plane:local`, `sam-router:local`, and `sam-node:local` images, loads them into the cluster, and deploys:-- The **hub**, configured to trust the cluster's own OIDC issuer.+- The **control plane**, configured to trust the cluster's own OIDC issuer.- Three **nodes** declared in `development/kind/mesh-config.yaml`: `node-a` (bare), `node-b` (hosts the `calc-mcp` example service), and `node-c` (hosts the `greeter-mcp` example service).Nodes authenticate to the hub via **Workload Identity Federation** (projected ServiceAccount tokens), so no static secrets or mock OIDC provider are needed. The hub is exposed to the host on `127.0.0.1:9090` (HTTP enroll) and `127.0.0.1:4001` (libp2p) via a NodePort and the cluster's `extraPortMappings` — `cloud-provider-kind` is not required.@@ -136,18 +136,20 @@ The manifests for the mock OIDC provider are available in [mock-oidc.yaml](manif[mock-oidc.yaml](manifests/mock-oidc.yaml ':include')-### SAM Hub Manifests+### SAM Control Plane and Router Manifests-The manifests for the SAM Hub are available in [sam-hub.yaml](manifests/sam-hub.yaml).+The manifests for the SAM Control Plane and Router are available in [sam-control-plane.yaml](manifests/sam-control-plane.yaml) and [sam-router.yaml](manifests/sam-router.yaml).-[sam-hub.yaml](manifests/sam-hub.yaml ':include')+[sam-control-plane.yaml](manifests/sam-control-plane.yaml ':include')++[sam-router.yaml](manifests/sam-router.yaml ':include')### Configuring Google OIDC (Optional)To use Google as the OIDC provider instead of the mock provider:2. **No Redirect URI required:** Because `sam-node` implements RFC 8252 (dynamic loopback port selection for native apps), you don't need to configure a specific Redirect URI when setting up a Desktop app. The authorization server will automatically allow loopback redirects.-3. **Update Secret:** Update the `sam-hub-secret` in `sam-hub.yaml` with your Google credentials:+3. **Update Secret:** Update the `sam-control-plane-secret` in `sam-control-plane.yaml` with your Google credentials:```yamlSAM_OIDC_ISSUER: "https://accounts.google.com"SAM_OIDC_ID: "<your-client-id>.apps.googleusercontent.com"@@ -169,7 +171,8 @@ cloud-provider-kind#### Step 3: Load Images into Kind```bash-kind load docker-image sam-hub:local --name sam-test+kind load docker-image sam-control-plane:local --name sam-test+kind load docker-image sam-router:local --name sam-testkind load docker-image sam-node:local --name sam-test```@@ -178,19 +181,21 @@ kind load docker-image sam-node:local --name sam-testIf using the **Mock OIDC Provider**:```bashkubectl apply -f mock-oidc.yaml-kubectl apply -f sam-hub.yaml+kubectl apply -f sam-control-plane.yaml+kubectl apply -f sam-router.yaml```If using **Google OIDC**:```bash-kubectl apply -f sam-hub.yaml+kubectl apply -f sam-control-plane.yaml+kubectl apply -f sam-router.yaml```#### Step 5: Get the External IPYou can use the following command to extract the allocated IP into an environment variable:```bash-HUB_IP=$(kubectl get svc sam-hub -o jsonpath='{.status.loadBalancer.ingress[0].ip}')+HUB_IP=$(kubectl get svc sam-control-plane -o jsonpath='{.status.loadBalancer.ingress[0].ip}')```---@@ -262,7 +267,7 @@ spec:command: ["sam-node", "run"]args:- "--hub"- - "http://sam-hub:9090"+ - "http://sam-control-plane:8080"- "--oidc-issuer"- "http://mock-oidc:18080"- "--client-id"@@ -313,7 +318,7 @@ sam-node run#### 3. Workload Identity Federation (Secretless Kubernetes)* **Description:** The current best practice in Kubernetes. It removes the need for static secrets entirely. The machine proves its identity based on where it is running by presenting a ServiceAccount token (a signed JWT issued by the K8s API).* **Use Case:** Production Kubernetes deployments.-* **How it works:** The Pod has a ServiceAccount token mounted. The Pod presents this token to the `sam-hub`. The hub verifies it by calling back to the Kubernetes OIDC discovery endpoint.+* **How it works:** The Pod has a ServiceAccount token mounted. The Pod presents this token to the `sam-control-plane`. The control plane verifies it by calling back to the Kubernetes OIDC discovery endpoint.* **How to use:** Pass the path to the mounted ServiceAccount token to the `--jwt-path` flag.* **Example:**```bash@@ -322,13 +327,13 @@ sam-node run \--jwt-path "/var/run/secrets/kubernetes.io/serviceaccount/token"```> [!NOTE]-> The `sam-hub` must be configured to trust the Kubernetes API server as an OIDC issuer for this flow to work.+> The `sam-control-plane` must be configured to trust the Kubernetes API server as an OIDC issuer for this flow to work.---## 5. Configuring Workload Identity in Kubernetes-Workload Identity allows `sam-node` pods to authenticate with the `sam-hub` using their Kubernetes ServiceAccount token, removing the need for static credentials.+Workload Identity allows `sam-node` pods to authenticate with the `sam-control-plane` using their Kubernetes ServiceAccount token, removing the need for static credentials.Here are the exact steps to configure this:@@ -340,16 +345,16 @@ kubectl get --raw /.well-known/openid-configuration | jq -r .issuer```(Or check your cloud provider's documentation for the public issuer URL).-### Step 2: Configure the Hub to trust the Kubernetes Issuer-Update the `sam-hub` deployment to include the Kubernetes issuer URL in the `--issuer` flag.+### Step 2: Configure the Control Plane to trust the Kubernetes Issuer+Update the `sam-control-plane` deployment to include the Kubernetes issuer URL in the `--issuer` flag.If you are using `kind`, the issuer URL is usually `https://kubernetes.default.svc.cluster.local` (internal) or the external URL mapped by kind.-Update `sam-hub.yaml`:+Update `sam-control-plane.yaml`:```yamlspec:containers:- - name: sam-hub+ - name: sam-control-planeargs:- "--issuer"- "https://accounts.google.com,https://kubernetes.default.svc.cluster.local"@@ -389,7 +394,7 @@ spec:command: ["sam-node", "run"]args:- "--hub"- - "http://sam-hub:9090"+ - "http://sam-control-plane:8080"- "--jwt-path"- "/var/run/secrets/tokens/sam-token"volumeMounts:@@ -403,5 +408,5 @@ spec:- serviceAccountToken:path: sam-tokenexpirationSeconds: 3600- audience: "sam-hub-audience" # Match this with what the hub expects+ audience: "sam-hub-audience" # Match this with what the control plane expects```diff --git a/site/content/docs/development/mobile.md b/site/content/docs/development/mobile.mdindex d4bd9eaa..67ae9d64 100644--- a/site/content/docs/development/mobile.md+++ b/site/content/docs/development/mobile.md@@ -118,7 +118,7 @@ If you have an active emulator running locally, you can run the full E2E orchest```#### What the E2E test validates:-1. Starts a local **Mock OIDC Server** and **sam-hub** process on the host.+1. Starts a local **Mock OIDC Server** and **sam-control-plane** process on the host.2. Registers a dummy tool (`host-tool`) on a host-level **sam-node**.3. Boots the **Android Emulator**, installs the FFI-embedded app, and starts the node inside the emulator.4. Registers an `emulator-tool` inside the emulator app.diff --git a/site/content/docs/development/policy.md b/site/content/docs/development/policy.mdindex d6f454fa..700a7ceb 100644--- a/site/content/docs/development/policy.md+++ b/site/content/docs/development/policy.md@@ -3,7 +3,7 @@ title: "SAM Policy & Authorization Reference"linkTitle: "SAM Policy & Authorization Reference"---SAM uses a decentralized authorization model powered by [Biscuit](https://www.biscuitsec.org/).-The `sam-hub` authenticates users via OIDC and injects **Facts** into their token based on `policies.yaml`. The `sam-node` operates offline, evaluating the token against baseline rules and optional local attenuation policies.+The `sam-control-plane` authenticates users via OIDC and injects **Facts** into their token based on `policies.yaml`. The `sam-node` operates offline, evaluating the token against baseline rules and optional local attenuation policies.> [!IMPORTANT]> **Default-Deny Security Posture**@@ -25,17 +25,17 @@ The Hub automatically translates OIDC claims into undeniable cryptographic facts| Expiration | `expiration(<date>)` | The token expiration date based on the OIDC session. |### 1.1 Translating Identity to Capability: OIDC to Biscuit-The core innovation of the SAM Network's security model is translating standard web identity (OIDC JSON Web Tokens defined in [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#Claims)) into decentralized capability tokens (Biscuits). This translation happens securely at the `sam-hub` during the authentication phase.+The core innovation of the SAM Network's security model is translating standard web identity (OIDC JSON Web Tokens defined in [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#Claims)) into decentralized capability tokens (Biscuits). This translation happens securely at the `sam-control-plane` during the authentication phase.The Datalog authority facts generated by the Hub are constructed using the Biscuit [Symbol Table specification](https://doc.biscuitsec.org/reference/specifications.html#symbol-table), ensuring compact serialization and cryptographically undeniable credentials.Here is exactly how an OIDC JWT is transformed into a policy-ready Biscuit:#### 1. Claim Extraction-When an agent or user submits a valid OIDC JWT, the sam-hub verifies the token's signature against the Identity Provider. Once validated, the Hub extracts the payload claims—typically attributes like sub (subject), email, and custom arrays like groups or roles.+When an agent or user submits a valid OIDC JWT, the sam-control-plane verifies the token's signature against the Identity Provider. Once validated, the Hub extracts the payload claims—typically attributes like sub (subject), email, and custom arrays like groups or roles.#### 2. Datalog Fact Generation-Biscuit policies are written in Datalog, a declarative logic language. The sam-hub acts as a translator, mapping the JSON claims from the OIDC token into immutable Datalog facts.+Biscuit policies are written in Datalog, a declarative logic language. The sam-control-plane acts as a translator, mapping the JSON claims from the OIDC token into immutable Datalog facts.For example, an incoming OIDC payload like this:@@ -57,7 +57,7 @@ group("engineering");```#### 3. Minting the Authority Block-The sam-hub takes these generated Datalog facts and embeds them into the Authority Block of a brand new Biscuit token. The Hub signs this block with its private cryptographic key.+The sam-control-plane takes these generated Datalog facts and embeds them into the Authority Block of a brand new Biscuit token. The Hub signs this block with its private cryptographic key.Because the facts are sealed in the Authority Block by the Hub, any sam-node in the mesh can implicitly trust that the user holding the Biscuit possesses those specific emails and groups.@@ -212,7 +212,7 @@ Here is a representative configuration for an engineering mesh deployment. It sh### 6.1 Central Hub Policy (`policies.yaml`)-Deploy this file on `sam-hub` to define global roles and user/service-account mappings.+Deploy this file on `sam-control-plane` to define global roles and user/service-account mappings.```yamlversion: "v1alpha1"diff --git a/site/content/docs/development/testing.md b/site/content/docs/development/testing.mdindex c9c760f2..27169df8 100644--- a/site/content/docs/development/testing.md+++ b/site/content/docs/development/testing.md@@ -38,7 +38,8 @@ go test ./tests/integration/...These tests validate current command behavior for:- `sam-node`-- `sam-hub`+- `sam-control-plane`+- `sam-router`Run:@@ -55,8 +56,9 @@ The container framework is implemented in:It starts:1. mock OIDC container-2. `sam-hub` container-3. multiple `sam-node` containers+2. `sam-control-plane` container+3. `sam-router` container+4. multiple `sam-node` containersRun:diff --git a/site/content/docs/manifests/sam-control-plane.yaml b/site/content/docs/manifests/sam-control-plane.yamlnew file mode 100644index 00000000..eb7bdc33--- /dev/null+++ b/site/content/docs/manifests/sam-control-plane.yaml@@ -0,0 +1,102 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++apiVersion: v1+kind: Secret+metadata:+ name: sam-control-plane-secret+type: Opaque+stringData:+ SAM_OIDC_ISSUER: "http://mock-oidc:18080"+---+apiVersion: apps/v1+kind: Deployment+metadata:+ name: sam-control-plane+ labels:+ app: sam-control-plane+spec:+ replicas: 1+ selector:+ matchLabels:+ app: sam-control-plane+ template:+ metadata:+ labels:+ app: sam-control-plane+ spec:+ containers:+ - name: sam-control-plane+ image: sam-control-plane:local+ imagePullPolicy: IfNotPresent+ args:+ - "--bind-address=0.0.0.0:8080"+ - "--db-driver=sqlite"+ - "--db-dsn=/data/control-plane.db"+ - "--issuer=$(SAM_OIDC_ISSUER)"+ - "--allowed-audiences=sam-mesh-audience,sam-hub-audience"+ - "--policy-file=/etc/sam/policies/policies.yaml"+ - "--insecure-skip-tls-verify"+ ports:+ - containerPort: 8080+ name: http+ env:+ - name: SAM_OIDC_ISSUER+ valueFrom:+ secretKeyRef:+ name: sam-control-plane-secret+ key: SAM_OIDC_ISSUER+ volumeMounts:+ - name: policies-volume+ mountPath: /etc/sam/policies+ readOnly: true+ - name: db-data+ mountPath: /data+ volumes:+ - name: policies-volume+ configMap:+ name: sam-control-plane-policies+ - name: db-data+ emptyDir: {}+---+apiVersion: v1+kind: Service+metadata:+ name: sam-control-plane+spec:+ type: ClusterIP+ selector:+ app: sam-control-plane+ ports:+ - protocol: TCP+ port: 8080+ targetPort: 8080+ name: http+---+apiVersion: v1+kind: ConfigMap+metadata:+ name: sam-control-plane-policies+data:+ policies.yaml: |+ version: "v1alpha1"+ bindings:+ - members: ["system:authenticated"]+ role: "public-mesh"+ roles:+ public-mesh:+ allowed_services:+ - "*"+ allowed_targets:+ - "*"diff --git a/site/content/docs/manifests/sam-hub.yaml b/site/content/docs/manifests/sam-hub.yamldeleted file mode 100644index 7afdf99b..00000000--- a/site/content/docs/manifests/sam-hub.yaml+++ /dev/null@@ -1,87 +0,0 @@-# Copyright 2026 Google LLC-#-# Licensed under the Apache License, Version 2.0 (the "License");-# you may not use this file except in compliance with the License.-# You may obtain a copy of the License at-#-# http://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing, software-# distributed under the License is distributed on an "AS IS" BASIS,-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-# See the License for the specific language governing permissions and-# limitations under the License.--apiVersion: v1-kind: Secret-metadata:- name: sam-hub-secret-type: Opaque-stringData:- SAM_HUB_KEY: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" # 32-byte hex- SAM_OIDC_ISSUER: "http://mock-oidc:18080"- SAM_OIDC_ID: "sam-e2e"- SAM_OIDC_SECRET: "sam-e2e-secret"-----apiVersion: apps/v1-kind: Deployment-metadata:- name: sam-hub- labels:- app: sam-hub-spec:- replicas: 1- selector:- matchLabels:- app: sam-hub- template:- metadata:- labels:- app: sam-hub- spec:- containers:- - name: sam-hub- image: sam-hub:local- imagePullPolicy: IfNotPresent- args:- - "--mesh=public-mesh"- - "--issuer=$(SAM_OIDC_ISSUER)"- ports:- - containerPort: 9090- name: public-port- env:- - name: SAM_HUB_KEY- valueFrom:- secretKeyRef:- name: sam-hub-secret- key: SAM_HUB_KEY- - name: SAM_OIDC_ISSUER- valueFrom:- secretKeyRef:- name: sam-hub-secret- key: SAM_OIDC_ISSUER- - name: SAM_OIDC_ID- valueFrom:- secretKeyRef:- name: sam-hub-secret- key: SAM_OIDC_ID- - name: SAM_OIDC_SECRET- valueFrom:- secretKeyRef:- name: sam-hub-secret- key: SAM_OIDC_SECRET-----apiVersion: v1-kind: Service-metadata:- name: sam-hub-spec:- type: LoadBalancer- selector:- app: sam-hub- ports:- - protocol: TCP- port: 9090- targetPort: 9090- name: public-port-diff --git a/site/content/docs/manifests/sam-router.yaml b/site/content/docs/manifests/sam-router.yamlnew file mode 100644index 00000000..569880f7--- /dev/null+++ b/site/content/docs/manifests/sam-router.yaml@@ -0,0 +1,88 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++apiVersion: v1+kind: ServiceAccount+metadata:+ name: sam-router-sa+---+apiVersion: apps/v1+kind: Deployment+metadata:+ name: sam-router+ labels:+ app: sam-router+spec:+ replicas: 1+ selector:+ matchLabels:+ app: sam-router+ template:+ metadata:+ labels:+ app: sam-router+ spec:+ serviceAccountName: sam-router-sa+ containers:+ - name: sam-router+ image: sam-router:local+ imagePullPolicy: IfNotPresent+ args:+ - "--control-plane=http://sam-control-plane:8080"+ - "--listen=/ip4/0.0.0.0/tcp/4501"+ - "--listen=/ip4/0.0.0.0/udp/4501/quic-v1"+ - "--jwt-path=/var/run/secrets/tokens/sam-token"+ - "--keys-path=/data/router.key"+ - "--allow-loopback"+ ports:+ - containerPort: 4501+ protocol: TCP+ name: p2p-tcp+ - containerPort: 4501+ protocol: UDP+ name: p2p-udp+ volumeMounts:+ - name: sam-token+ mountPath: /var/run/secrets/tokens+ readOnly: true+ - name: router-data+ mountPath: /data+ volumes:+ - name: sam-token+ projected:+ sources:+ - serviceAccountToken:+ path: sam-token+ expirationSeconds: 3600+ audience: "sam-hub-audience"+ - name: router-data+ emptyDir: {}+---+apiVersion: v1+kind: Service+metadata:+ name: sam-router+spec:+ type: LoadBalancer+ selector:+ app: sam-router+ ports:+ - protocol: TCP+ port: 4501+ targetPort: 4501+ name: p2p-tcp+ - protocol: UDP+ port: 4501+ targetPort: 4501+ name: p2p-udpdiff --git a/site/content/docs/quickstart.md b/site/content/docs/quickstart.mdindex c12e28f5..32ab7d16 100644--- a/site/content/docs/quickstart.md+++ b/site/content/docs/quickstart.md@@ -20,7 +20,10 @@ curl -sL https://sam-mesh.dev/install.sh | bashIf you have Go installed, you can compile and install directly from the repository:```bashgo install github.com/google/sam/cmd/sam-node@latest-go install github.com/google/sam/cmd/sam-hub@latest++# Optional: if you want to run your own control plane and router:+go install github.com/google/sam/cmd/sam-control-plane@latest+go install github.com/google/sam/cmd/sam-router@latest```### Option C: PowerShell (Windows)diff --git a/site/content/docs/user/agent-usage.md b/site/content/docs/user/agent-usage.mdindex fdf2af0a..9e7043cc 100644--- a/site/content/docs/user/agent-usage.md+++ b/site/content/docs/user/agent-usage.md@@ -15,12 +15,12 @@ Connecting your AI agent to the Sovereign Agent Mesh involves two phases:sequenceDiagramactor User as Developer/Operatorparticipant Node as sam-node (Local)- participant Hub as sam-hub (Mesh)+ participant Hub as sam-control-plane (Mesh)participant Agent as AI Agent (Gemini/Claude)Note over User,Hub: Phase 1: Mesh Join (OIDC Authorization)- User->>Node: sam-node join <hub-url>- Node->>Hub: Get Hub OIDC Info+ User->>Node: sam-node join <control-plane-url>+ Node->>Hub: Get OIDC InfoHub-->>Node: OIDC Issuer, Client IDNode->>User: Display Login URL & CodeUser->>User: Login in Browserdiff --git a/site/content/docs/user/control-plane-configuration.md b/site/content/docs/user/control-plane-configuration.mdnew file mode 100644index 00000000..14691b57--- /dev/null+++ b/site/content/docs/user/control-plane-configuration.md@@ -0,0 +1,121 @@+---+title: "Control Plane & Router Configuration Guide"+linkTitle: "Control Plane & Router Configuration"+weight: 10+---++The SAM architecture separates the OIDC capabilities control plane (`sam-control-plane`) from the GossipSub network routers (`sam-router`).++---++## 1. SAM Control Plane (`sam-control-plane`)++The Control Plane is responsible for bridging user identities from trusted OIDC providers, issuing cryptographically signed Biscuit authorization tokens, and distributing network/tool policies to routers and nodes.++### Command-Line Arguments & Environment Variables++| CLI Flag | Environment Variable | Default Value | Description |+| :--- | :--- | :--- | :--- |+| `--issuer` | `SAM_OIDC_ISSUER` | *None* (Required) | Comma-separated list of trusted OIDC Provider URLs. |+| `--bind-address` | *None* | `0.0.0.0:8080` | Host and port to listen on for HTTP web API service. |+| `--db-driver` | *None* | `sqlite` | Database driver (`sqlite` or `postgres`). |+| `--db-dsn` | *None* | `control-plane.db` | Database DSN/Connection URL (e.g. `postgres://user:pass@host:5432/db`). |+| `--allowed-audiences` | *None* | `sam-mesh-audience` | Comma-separated list of allowed JWT audiences. |+| `--policy-file` | *None* | `policies.yaml` | Path to the YAML file defining authorization roles and bindings (bootstrapping only). |+| `--admin-token` | *None* | *None* | Secret token string required in the HTTP Header `Authorization: Bearer <token>` for admin operations. |+| `--insecure-skip-tls-verify` | *None* | `false` | Set to `true` to skip certificate validation for development/testing OIDC providers. |+| `--key-rotation-interval` | *None* | `24h` | Key rotation interval (e.g. `24h`). `0s` disables rotation. |+| `--key-grace-period` | *None* | `1h` | Key grace period for rotated keys. |+| `--lease-duration` | *None* | `15m` | Router lease registration TTL. |++---++## 2. SAM Router (`sam-router`)++The Router is a dedicated GossipSub helper that maintains stable network addresses (multiaddrs) and relays mesh overlays for discovery.++### Command-Line Arguments & Environment Variables++| CLI Flag | Default Value | Description |+| :--- | :--- | :--- |+| `--control-plane` | `http://127.0.0.1:8080` | Control Plane web service URL. |+| `--listen` | `/ip4/0.0.0.0/tcp/5001`, `/ip6/::/tcp/5001` | Comma-separated libp2p multiaddrs to listen on. |+| `--external-addr` | *None* | External multiaddrs to announce to control plane. |+| `--keys-path` | `router.key` | Path to save/load persistent private key (determines Peer ID). |+| `--jwt-path` | *None* | Path to file containing OIDC JWT token for enrollment. |+| `--oidc-token` | *None* | Direct OIDC ID token or bootstrap secret token for enrollment. |+| `--keys-sync-interval` | `5m` | Key synchronization polling interval. |+| `--lease-renew-interval` | `300s` | Lease renewal registration interval. |+| `--allow-loopback` | `false` | Allow loopback and link-local addresses for discovery (development only). |++---++## 3. Configuring Role-Based Policies (`policies.yaml`)++The Control Plane dynamically issues permissions inside the Biscuit token based on identity claims (users or groups) mapped to specific roles in the policy file.++The policy defines what endpoints and services agents are permitted to use:+* **`allowed_targets`**: Restricts which logical endpoints the agent can route connections to. Use resolved Biscuit facts: `group:<name>`, `user:<sub-id>`, `email:<email>`, `role:<role-name>`, or `node:<peer-id>`.+* **`allowed_services`**: Restricts the application-level services the agent can invoke. Services are prefixed by their protocol type and URI scheme (e.g., `mcp://local-shell-tools` or `inference://openrouter`). Wildcards are supported (e.g., `mcp://*`).++### Example Policy Mapping+Create a `policies.yaml` file in the directory where you run `sam-control-plane`:++```yaml+version: v1alpha1++# Define authorization roles and their specific network/tool permissions+roles:+ developer-role:+ allowed_targets:+ - "group:dev-nodes"+ - "email:[email protected]"+ - "user:auth0|123456"+ - "node:12D3KooWSpecificDevNodeId"+ allowed_services:+ - "mcp://local-shell-tools"+ - "mcp://git-helper"+ - "inference://openrouter"++ admin-role:+ allowed_targets:+ - "group:all-nodes"+ - "role:admin"+ allowed_services:+ - "mcp://*"+ - "inference://*"+ - "system://*"++# Bind OIDC user subs, emails, or group claims to roles+bindings:+ - members: ["email:[email protected]"]+ role: "admin-role"+ - members: ["user:auth0|123456"]+ role: "admin-role"+ - members: ["group:eng-team"]+ role: "developer-role"+```++---++## 4. Bootstrapping Example++Here is a script demonstrating how to boot both services in a secure development environment:++```bash+# 1. Start the Control Plane (using SQLite and policies)+./bin/sam-control-plane \+ --issuer "https://accounts.google.com" \+ --allowed-audiences "my-google-client-id.apps.googleusercontent.com" \+ --policy-file "./policies.yaml" \+ --bind-address "0.0.0.0:8080" \+ --admin-token "super-secret-admin-token"++# 2. In another shell, start the Router using a bootstrap JWT or token+./bin/sam-router \+ --control-plane "http://127.0.0.1:8080" \+ --listen "/ip4/0.0.0.0/tcp/5001" \+ --listen "/ip4/0.0.0.0/udp/5001/quic-v1" \+ --keys-path "./router.key" \+ --oidc-token "my-router-jwt-token"+```diff --git a/site/content/docs/user/hub-configuration.md b/site/content/docs/user/hub-configuration.mddeleted file mode 100644index 1ba1742e..00000000--- a/site/content/docs/user/hub-configuration.md+++ /dev/null@@ -1,111 +0,0 @@-----title: "Hub Configuration Guide"-linkTitle: "Hub Configuration"-weight: 10------The `sam-hub` acts as the control plane for the Sovereign Agent Mesh. It is responsible for bridging user identities from OpenID Connect (OIDC) providers, issuing cryptographically signed Biscuit authorization tokens, and distributing network and tool policies to nodes.-------## 1. Core Services--When you run `sam-hub`, it launches two core service endpoints:-1. **libp2p P2P Endpoint**: Used by `sam-node` clients to execute cryptographic handshakes and perform DHT resource discovery.-2. **HTTP/HTTPS Service Endpoint**: Used for health status checks (`/healthz`), prometheus metrics (`/metrics`), and administrative commands (like banning nodes).-------## 2. Command-Line Arguments & Environment Variables--The hub is highly configurable. Each setting can be passed as a command-line flag or bound to a corresponding environment variable:--| CLI Flag | Environment Variable | Default Value | Description |-| :--- | :--- | :--- | :--- |-| `--issuer` | `SAM_OIDC_ISSUER` | `https://accounts.google.com` | Comma-separated list of trusted OIDC Provider URLs. |-| `--client-id` | `SAM_OIDC_ID` | *None* | Client ID registered with the OIDC provider. |-| `--key` | `SAM_HUB_KEY` | *None* | Private Key seed (32-byte hexadecimal string) used to sign Biscuit tokens. |-| `--listen` | *None* | `[]` | Comma-separated libp2p multiaddrs to listen on (e.g. `/ip4/0.0.0.0/tcp/9090`). |-| `--bind-address` | *None* | `:9090` | Host and port to listen on for the HTTP/HTTPS admin service. |-| `--policy-file` | *None* | `policies.yaml` | Path to the YAML file defining authorization roles and bindings. |-| `--allowed-audiences` | *None* | `sam-mesh-audience` | Comma-separated list of allowed JWT audiences. |-| `--insecure-skip-tls-verify` | *None* | `false` | Set to `true` to skip certificate validation for development/testing OIDC providers. |-| `--keys-db` | *None* | `keys.db` | Path to the BoltDB file storing public/private keys for token validation. |-| `--admin-token` | *None* | *None* | Secret token string required in the HTTP Header `Authorization: Bearer <token>` for admin operations. |-| `--tls-cert-file` | *None* | *None* | Path to the TLS certificate file (enables HTTPS on the admin server). |-| `--tls-key-file` | *None* | *None* | Path to the TLS private key file. |-------## 3. Configuring Role-Based Policies (`policies.yaml`)--The hub dynamically issues permissions inside the Biscuit token based on identity claims (users or groups) mapped to specific roles in the policy file.--The policy defines what endpoints and services agents are permitted to use:-* **`allowed_targets`**: Acts similar to Active Directory network groups. This restricts which logical endpoints the agent can route connections to. **Note: IP address ranges are not allowed.** Instead, use the format of the resolved Biscuit facts: `group:<name>`, `user:<sub-id>`, `email:<email>`, `role:<role-name>`, or `node:<peer-id>`.-* **`allowed_services`**: Restricts the application-level services the agent can invoke. Services are prefixed by their protocol type and URI scheme (e.g., `mcp://local-shell-tools` or `inference://openrouter`).--> [!NOTE]-> SAM natively supports domain-level prefix and suffix wildcards in `allowed_services`. You can grant access to an entire type via `mcp://*`, allow prefix wildcard matching like `mcp://*.service.local` (matching services ending in `.service.local`), suffix wildcard matching like `mcp://service.*` (matching services starting with `service.`), or grant global access to everything via `*`. Note that arbitrary partial matches (e.g., `dev-*` or `*-prod`) are not supported because they do not align with domain boundaries and will fail DNS name validation.--### Example Policy Mapping-Create a `policies.yaml` file in the directory where you run `sam-hub`:--```yaml-version: v1alpha1--# Define authorization roles and their specific network/tool permissions-roles:- developer-role:- allowed_targets:- - "group:dev-nodes"- - "email:[email protected]"- - "user:auth0|123456"- - "node:12D3KooWSpecificDevNodeId"- allowed_services:- - "mcp://local-shell-tools"- - "mcp://git-helper"- - "inference://openrouter"-- admin-role:- allowed_targets:- - "group:all-nodes"- - "role:admin"- allowed_services:- - "mcp://*"- - "inference://*"- - "system://*"--# Bind OIDC user subs, emails, or group claims to roles-bindings:- - members: ["email:[email protected]"]- role: "admin-role"- - members: ["user:auth0|123456"]- role: "admin-role"- - members: ["group:eng-team"]- role: "developer-role"-```-------## 4. Bootstrapping Example--Here is a script demonstrating how to boot the hub in a secure development environment using Google Accounts as the OIDC provider:--```bash-# 1. Generate a secure 32-byte signing seed-export SAM_HUB_KEY=$(openssl rand -hex 32)--# 2. Configure environment settings-export SAM_OIDC_ISSUER="https://accounts.google.com"-export SAM_OIDC_ID="my-google-client-id.apps.googleusercontent.com"--# 3. Launch sam-hub with HTTPS and policies configured-./bin/sam-hub \- --listen "/ip4/0.0.0.0/tcp/5001/udp/5001/quic-v1" \- --policy-file "./policies.yaml" \- --bind-address "0.0.0.0:9090" \- --admin-token "super-secret-admin-token" \- --tls-cert-file "/etc/sam/certs/hub.crt" \- --tls-key-file "/etc/sam/certs/hub.key"-```diff --git a/site/content/docs/user/kubernetes-deployment.md b/site/content/docs/user/kubernetes-deployment.mdindex e8b11a6a..e1b9ad05 100644--- a/site/content/docs/user/kubernetes-deployment.md+++ b/site/content/docs/user/kubernetes-deployment.md@@ -12,15 +12,18 @@ This guide explains how to deploy a production-grade SAM cluster (Hub, DNS synchA production SAM deployment consists of:* **Dex (OIDC Provider)**: Serves as the identity bridge, federation point, and login broker.-* **SAM Hub (`sam-hub`)**: Runs as a **StatefulSet** to maintain stable network identity. P2P nodes query these bootstrap pods to connect to the mesh.-* **DNS Sync CronJob**: Dynamically queries the StatefulSet pod IP addresses and updates DNS A/AAAA records for P2P bootstrap resolution.-* **SAM Nodes (`sam-node`)**: Deployed as containerized gateways that authenticate securely to the hub using Kubernetes Workload Identity (ServiceAccount token projection).+* **SAM Control Plane (`sam-control-plane`)**: Runs as a stateless **Deployment** to verify OIDC tokens and issue capabilities (Biscuits) based on identity policies.+* **SAM Router (`sam-router`)**: Runs as a **StatefulSet** to maintain stable network identity. P2P nodes use these bootstrap routers to connect to the GossipSub mesh overlay.+* **DNS Sync CronJob**: Dynamically queries the `sam-router` StatefulSet pod IP addresses and updates DNS A/AAAA records for P2P bootstrap resolution.+* **SAM Nodes (`sam-node`)**: Deployed as containerized gateways that authenticate securely to the control plane using Kubernetes Workload Identity (ServiceAccount token projection).```mermaidgraph TDUser([User / Client]) -->|HTTPS / OIDC| Dex[Dex Identity Bridge]- Node[sam-node Gateway Pod] -->|ServiceAccount Token| Hub[sam-hub StatefulSet]- Hub -->|OIDC Discovery Check| Dex+ Node[sam-node Gateway Pod] -->|HTTPS Enroll| CP[sam-control-plane Deployment]+ Router[sam-router StatefulSet] -->|HTTPS Enroll| CP+ Node -->|P2P Mesh Overlay| Router+ CP -->|OIDC Discovery Check| DexCron[DNS Sync CronJob] -->|Poll Pod IPs| K8sApi[Kubernetes API]Cron -->|Update A Records| CloudDNS[Cloud DNS / DNS Registry]Node -->|Bootstrap DNS Resolution| CloudDNS@@ -86,26 +89,17 @@ kubectl rollout status deployment/dex -n dex----## 3. Step 2: Deploying the SAM Hub+## 3. Step 2: Deploying SAM Control Plane and Router-The SAM Hub must have a stable network identifier (multiaddr) so nodes can discover it.+The Control Plane verifies OIDC tokens and manages access policies. The Routers handle peer discovery and routing within the GossipSub mesh.-### 1. Generate the Hub Private Key Secret-Generate and save a random 32-byte signing seed key:-```bash-HUB_KEY=$(openssl rand -hex 32)-kubectl create secret generic sam-hub-secret \- --namespace=sam \- --from-literal=sam-hub-key="${HUB_KEY}"-```--### 2. Configure Access Control policies (`policies.yaml`)-Map identities (ServiceAccounts or email handles) to authorized roles. Save this as a ConfigMap:+### 1. Configure Access Control Policies (`policies.yaml`)+Create a ConfigMap defining your global mesh access rules:```yamlapiVersion: v1kind: ConfigMapmetadata:- name: sam-hub-policies+ name: sam-control-plane-policiesnamespace: samdata:policies.yaml: |@@ -115,43 +109,88 @@ data:role: "node-role"roles:node-role:- mcp:- allowed_services:- - "system:sam.catalog"+ allowed_services:+ - "*"+ allowed_targets:+ - "*"``````bashkubectl apply -f policies-configmap.yaml```-### 3. Deploy the Hub StatefulSet-Deploy a StatefulSet to allocate stable hostnames (`sam-hub-0`, `sam-hub-1`):+### 2. Deploy SAM Control Plane+The Control Plane is stateless and can scale horizontally. It connects to a shared PostgreSQL database to persist active leases and rotated capability signing keys.+```yamlapiVersion: apps/v1+kind: Deployment+metadata:+ name: sam-control-plane+ namespace: sam+spec:+ replicas: 3+ selector:+ matchLabels:+ app: sam-control-plane+ template:+ metadata:+ labels:+ app: sam-control-plane+ spec:+ containers:+ - name: sam-control-plane+ image: ghcr.io/google/sam-control-plane:latest+ args:+ - "--bind-address=0.0.0.0:8080"+ - "--db-driver=postgres"+ - "--db-dsn=postgres://sam:password@sam-db-service:5432/sam_mesh?sslmode=disable"+ - "--issuer=https://AUTH.YOUR-DOMAIN.COM"+ - "--allowed-audiences=YOUR-CLIENT-AUDIENCE"+ - "--policy-file=/etc/sam/policies/policies.yaml"+ ports:+ - containerPort: 8080+ name: http+ volumeMounts:+ - name: policies-volume+ mountPath: /etc/sam/policies+ readOnly: true+ volumes:+ - name: policies-volume+ configMap:+ name: sam-control-plane-policies+```++### 3. Deploy SAM Router StatefulSet+The Router must be deployed as a StatefulSet to allocate a persistent volume for storing its libp2p identity key, ensuring a stable Peer ID across pod restarts.++```yaml+apiVersion: v1+kind: ServiceAccount+metadata:+ name: sam-router-sa+ namespace: sam+---+apiVersion: apps/v1kind: StatefulSetmetadata:- name: sam-hub+ name: sam-routernamespace: samspec:- serviceName: "sam-hub"+ serviceName: "sam-router"replicas: 3+ selector:+ matchLabels:+ app: sam-routertemplate:+ metadata:+ labels:+ app: sam-routerspec:+ serviceAccountName: sam-router-sacontainers:- - name: sam-hub- image: ghcr.io/google/sam-hub:latest- env:- - name: HOST_IP- valueFrom:- fieldRef:- fieldPath: status.hostIP- - name: SAM_HUB_KEY- valueFrom:- secretKeyRef:- name: sam-hub-secret- key: sam-hub-key+ - name: sam-router+ image: ghcr.io/google/sam-router:latestports:- - containerPort: 9090- name: metrics- containerPort: 4501protocol: TCPname: p2p-tcp@@ -159,19 +198,33 @@ spec:protocol: UDPname: p2p-udpargs:+ - "--control-plane=http://sam-control-plane.sam.svc.cluster.local:8080"- "--listen=/ip4/0.0.0.0/tcp/4501"- "--listen=/ip4/0.0.0.0/udp/4501/quic-v1"- - "--external-multiaddr=/dnsaddr/BOOTSTRAP.YOUR-DOMAIN.COM"- - "--issuer=https://AUTH.YOUR-DOMAIN.COM"- - "--allowed-audiences=YOUR-CLI-AUDIENCE"- - "--policy-file=/etc/sam/policies/policies.yaml"+ - "--jwt-path=/var/run/secrets/tokens/sam-token"+ - "--keys-path=/data/router.key"volumeMounts:- - name: policies-volume- mountPath: /etc/sam/policies+ - name: sam-token+ mountPath: /var/run/secrets/tokens+ readOnly: true+ - name: router-data+ mountPath: /datavolumes:- - name: policies-volume- configMap:- name: sam-hub-policies+ - name: sam-token+ projected:+ sources:+ - serviceAccountToken:+ path: sam-token+ expirationSeconds: 3600+ audience: "sam-hub-audience"+ volumeClaimTemplates:+ - metadata:+ name: router-data+ spec:+ accessModes: [ "ReadWriteOnce" ]+ resources:+ requests:+ storage: 1Gi```---@@ -182,7 +235,7 @@ In a decentralized DHT network, nodes need stable DNS multiaddrs (`/dnsaddr/BOOT### DNS Sync CronJob ExampleThe sync script:-1. Queries the Kubernetes API for the external/internal IP addresses of the `sam-hub` pods.+1. Queries the Kubernetes API for the external/internal IP addresses of the `sam-router` pods.2. Updates your Cloud DNS zone (e.g. Google Cloud DNS, AWS Route53) dynamically.3. Announce new multiaddrs via TXT records.@@ -227,7 +280,7 @@ data:```### 3. Deploy Nodes using Token Projection-Deploy the nodes. We use a `projected` volume to request a short-lived token containing the audience expected by the hub (`sam-hub-audience`):+Deploy the nodes. We use a `projected` volume to request a short-lived token containing the audience expected by the control plane (`sam-hub-audience`):```yamlapiVersion: apps/v1@@ -246,7 +299,7 @@ spec:args:- "run"- "--config=/etc/sam/sam-node.yaml"- - "--hub=http://sam-hub.sam.svc.cluster.local:9090"+ - "--hub=http://sam-control-plane.sam.svc.cluster.local:8080"- "--jwt-path=/var/run/secrets/tokens/sam-token"- "--api-token=secret-token"volumeMounts:@@ -265,7 +318,7 @@ spec:- serviceAccountToken:path: sam-tokenexpirationSeconds: 3600- audience: "sam-hub-audience"+ audience: "sam-hub-audience" # Match this with what the control plane expects```---diff --git a/tests/e2e/fixtures/sam-hub.yaml b/tests/e2e/fixtures/control-plane-router.yamlsimilarity index 100%rename from tests/e2e/fixtures/sam-hub.yamlrename to tests/e2e/fixtures/control-plane-router.yamldiff --git a/tests/e2e/lib/container_mesh.bash b/tests/e2e/lib/container_mesh.bashindex f2b2cb34..432d189d 100644--- a/tests/e2e/lib/container_mesh.bash+++ b/tests/e2e/lib/container_mesh.bash@@ -276,7 +276,7 @@ if [[ -z "${MESH_HELPERS_LOADED:-}" ]]; thenkubectl --context="${KUBECONTEXT}" create secret generic sam-router-token --from-literal=token="${router_token}" --dry-run=client -o yaml | kubectl --context="${KUBECONTEXT}" apply -f -- envsubst '$ISSUERS' < tests/e2e/fixtures/sam-hub.yaml | kubectl --context="${KUBECONTEXT}" apply -f -+ envsubst '$ISSUERS' < tests/e2e/fixtures/control-plane-router.yaml | kubectl --context="${KUBECONTEXT}" apply -f -kubectl --context="${KUBECONTEXT}" rollout restart deployment/sam-db || truekubectl --context="${KUBECONTEXT}" rollout status deployment/sam-db --timeout=60skubectl --context="${KUBECONTEXT}" rollout restart deployment/sam-control-plane