Skip to content

Agent Mesh

fix hub key

Antonio Ojea1da149d51a1b
diff --git a/.github/k8s/sam-hub-template.yaml b/.github/k8s/sam-hub-template.yaml
index 40f0476e..d0487042 100644
--- a/.github/k8s/sam-hub-template.yaml
+++ b/.github/k8s/sam-hub-template.yaml
@@ -57,6 +57,13 @@ spec:
containers:
- name: sam-hub
image: ghcr.io/google/sam-hub:${IMAGE_TAG}
+ env:
+ - 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: 4001
protocol: TCP
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 285adb4e..93fc5efb 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -157,6 +157,21 @@ jobs:
exit 1
}
+ - name: Provision Hub Secrets
+ run: |
+ export ENV_NAME="${{ vars.ENV_NAME }}"
+ export NAMESPACE="sam-${ENV_NAME}"
+ # Idempotently provision the sam-hub-secret if it doesn't already exist
+ if ! kubectl get secret sam-hub-secret -n ${NAMESPACE} >/dev/null 2>&1; then
+ echo "Generating a new random 32-byte hex key for SAM_HUB_KEY..."
+ HUB_KEY=$(openssl rand -hex 32)
+ kubectl create secret generic sam-hub-secret \
+ --namespace=${NAMESPACE} \
+ --from-literal=sam-hub-key="${HUB_KEY}"
+ else
+ echo "sam-hub-secret already exists in namespace ${NAMESPACE}. Skipping generation."
+ fi
+
- name: Deploy Hub
run: |
sudo apt-get install -y gettext-base
diff --git a/cmd/sam-node/node.go b/cmd/sam-node/node.go
index 28215d99..0524ea08 100644
--- a/cmd/sam-node/node.go
+++ b/cmd/sam-node/node.go
@@ -418,11 +418,11 @@ func (n *SamNode) listenForHubEvents(ctx context.Context) {
continue
}
- // use the original author not the one that just relay the message
- if msg.GetFrom() != n.HubPeerID {
- logger.Warnf("[Mesh Event] Ignored event from non-hub peer: %s", msg.ReceivedFrom)
- continue
- }
+ // Since the signature is verified against our list of trusted hub public keys
+ // in verifyEvent below, any message with a valid signature is cryptographically
+ // proven to have been authored by one of the hubs. We do not restrict msg.GetFrom()
+ // to a single HubPeerID because there can be multiple hub replicas in a cluster,
+ // each with its own PeerID.
if !n.verifyEvent(&event) {
logger.Warnf("[Mesh Event] Potential spoofing attempt: invalid signature on event from %s", msg.ReceivedFrom)
diff --git a/docs/release-tracks.md b/docs/release-tracks.md
new file mode 100644
index 00000000..d1895c5d
--- /dev/null
+++ b/docs/release-tracks.md
@@ -0,0 +1,39 @@
+# Release Tracks, Autoupdate, and Autoscaling
+
+Sovereign Agent Mesh (SAM) is deployed to public endpoints using automated environments, release tracks, and self-healing/scaling infrastructure.
+
+---
+
+## 1. Release Tracks
+
+The public deployment has two isolated release tracks:
+
+### A. Testnet Track (Bananas)
+* **Domain Name:** `bananas.sam-mesh.dev`
+* **Source Branch:** Tracks the `main` branch.
+* **Deployment Trigger:** Automatically deployed on every new push/commit to the `main` branch.
+* **Target Tag:** The deployment is tagged with the Git commit SHA (`github.sha`).
+* **Purpose:** Serves as the staging/testing playground for the latest features and continuous integration.
+
+### B. Production Track (Hub)
+* **Domain Name:** `hub.sam-mesh.dev`
+* **Source Branch:** Tracks semantic version tags matching `v*.*.*`.
+* **Deployment Trigger:** Automatically deployed whenever a new version tag is pushed to GitHub.
+* **Target Tag:** The deployment is tagged with the exact Git release tag (e.g. `v1.0.0`).
+* **Purpose:** Stable, audited release track for production workloads.
+
+---
+
+## 2. Autoupdate Mechanism
+
+Updates to both release tracks are fully automated via a robust **Continuous Deployment** pipeline:
+
+1. **GitHub Actions Trigger:** The workflow defined in [.github/workflows/deploy.yaml](file:///usr/local/google/home/aojea/src/sam/.github/workflows/deploy.yaml) is automatically triggered by repository events (pushing to `main` or pushing a version tag).
+2. **Determining the Track & Tag:**
+ * If the event is a release tag, the pipeline dynamically targets the `hub` GitHub environment and sets the container image tag to the release version.
+ * Otherwise, it targets the `bananas` environment and sets the container image tag to the Git commit SHA.
+3. **Rolling Updates:**
+ * Images are built and pushed to GitHub Container Registry (`ghcr.io`).
+ * The workflow executes `kubectl apply` on the Kubernetes templates.
+ * Kubernetes uses a `RollingUpdate` strategy, updating the pods one-by-one. This guarantees **zero-downtime** updates while replacing running processes with the new version.
+ * The workflow executes `kubectl rollout status` to verify that the new pods become healthy and ready. If an update fails, GKE automatically rolls back to the previous stable version.