Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
deploy public mesh
Antonio Ojea6d38cb8d7d50
diff --git a/.github/k8s/sam-hub-template.yaml b/.github/k8s/sam-hub-template.yamlnew file mode 100644index 00000000..020aaacb--- /dev/null+++ b/.github/k8s/sam-hub-template.yaml@@ -0,0 +1,48 @@+apiVersion: v1+kind: Service+metadata:+ name: sam-hub-${ENV_NAME}+ namespace: ${NAMESPACE}+spec:+ type: LoadBalancer+ loadBalancerIP: ${LOAD_BALANCER_IP}+ ports:+ - port: 4001+ targetPort: 4001+ protocol: TCP+ name: libp2p+ selector:+ app: sam-hub-${ENV_NAME}+---+apiVersion: apps/v1+kind: Deployment+metadata:+ name: sam-hub-${ENV_NAME}+ namespace: ${NAMESPACE}+spec:+ replicas: 1+ selector:+ matchLabels:+ app: sam-hub-${ENV_NAME}+ template:+ metadata:+ labels:+ app: sam-hub-${ENV_NAME}+ spec:+ containers:+ - name: sam-hub+ image: your-registry/sam-hub:${IMAGE_TAG}+ ports:+ - containerPort: 4001+ env:+ - name: SAM_EXTERNAL_MULTIADDR+ value: "${EXTERNAL_MULTIADDR}"++ # Critical for multi-tenant clusters: prevent testnet from starving prod+ resources:+ requests:+ cpu: 100m+ memory: 128Mi+ limits:+ cpu: 500m+ memory: 512Midiff --git a/.github/k8s/sam-node-template.yaml b/.github/k8s/sam-node-template.yamlnew file mode 100644index 00000000..b4fe6e19--- /dev/null+++ b/.github/k8s/sam-node-template.yaml@@ -0,0 +1,85 @@+apiVersion: v1+kind: ConfigMap+metadata:+ name: sam-canary-config-${ENV_NAME}+ namespace: sam-canary-${ENV_NAME}+data:+ sam-node.yaml: |+ version: "v1alpha1"+ attenuation:+ policies: []+ checks: []+ rules: []+ services:+ - type: mcp+ name: dummy-http+ description: "Canary HTTP tool (k8s agnhost)"+ # agnhost netexec responds with request info on the root path+ target_url: "http://localhost:9090/"+ - type: mcp+ name: dummy-stdio+ description: "Canary Stdio tool via injected busybox"+ # We call the injected busybox binary explicitly+ command: ["/shared/busybox", "sh", "-c", "while read line; do echo '{\"jsonrpc\": \"2.0\", \"id\": 1, \"result\": {\"status\": \"canary-alive\"}}'; done"]+---+apiVersion: apps/v1+kind: Deployment+metadata:+ name: sam-canary-${ENV_NAME}+ namespace: sam-canary-${ENV_NAME}+spec:+ replicas: 2+ selector:+ matchLabels:+ app: sam-canary-${ENV_NAME}+ template:+ metadata:+ labels:+ app: sam-canary-${ENV_NAME}+ spec:+ # 1. The Init Container: Copies busybox to the shared volume+ initContainers:+ - name: inject-busybox+ image: busybox:1.36.1+ command: ["cp", "/bin/busybox", "/shared/busybox"]+ volumeMounts:+ - name: shared-bin+ mountPath: /shared++ containers:+ # 2. The SAM Agent (Distroless)+ - name: sam-node+ image: ghcr.io/google/sam-node:${IMAGE_TAG}+ args:+ - "run"+ - "--config=/etc/sam/sam-node.yaml"+ - "--hub=/dns4/sam-hub-${ENV_NAME}.sam-${ENV_NAME}.svc.cluster.local/tcp/4001"+ ports:+ - containerPort: 8080+ resources:+ requests:+ cpu: 50m+ memory: 64Mi+ limits:+ cpu: 200m+ memory: 256Mi+ volumeMounts:+ - name: config-volume+ mountPath: /etc/sam+ - name: shared-bin+ mountPath: /shared++ # 3. The Dummy MCP Backend Sidecar+ - name: mock-mcp-server+ image: registry.k8s.io/e2e-test-images/agnhost:2.39+ # agnhost's netexec subcommand spins up a robust test HTTP server+ args: ["netexec", "--http-port=9090"]+ ports:+ - containerPort: 9090++ volumes:+ - name: config-volume+ configMap:+ name: sam-canary-config-${ENV_NAME}+ - name: shared-bin+ emptyDir: {}diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yamlnew file mode 100644index 00000000..94730de4--- /dev/null+++ b/.github/workflows/deploy.yaml@@ -0,0 +1,159 @@+name: Deploy SAM Hub++on:+ push:+ branches:+ - main+ tags:+ - 'v*.*.*'+ workflow_dispatch:++env:+ REGISTRY: ghcr.io++jobs:+ publish:+ name: Publish Images+ runs-on: ubuntu-latest+ permissions:+ packages: write+ contents: read+ timeout-minutes: 100++ steps:+ - name: Check out code+ uses: actions/checkout@v4++ - name: Set up QEMU+ uses: docker/setup-qemu-action@v3++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v3++ - name: Log in to the Container registry+ uses: docker/login-action@v3+ with:+ registry: ${{ env.REGISTRY }}+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Extract metadata for Hub+ id: meta-hub+ uses: docker/metadata-action@v5+ with:+ images: ${{ env.REGISTRY }}/google/sam-hub+ tags: |+ type=ref,event=branch+ type=ref,event=tag+ type=raw,value=${{ github.sha }}+ type=raw,value=latest,enable={{is_default_branch}}+ type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }}++ - name: Build and push Hub image+ uses: docker/build-push-action@v6+ with:+ context: .+ file: Dockerfile.sam-hub+ platforms: linux/amd64,linux/arm64+ push: true+ tags: ${{ steps.meta-hub.outputs.tags }}+ labels: ${{ steps.meta-hub.outputs.labels }}++ - name: Extract metadata for Node+ id: meta-node+ uses: docker/metadata-action@v5+ with:+ images: ${{ env.REGISTRY }}/google/sam-node+ tags: |+ type=ref,event=branch+ type=ref,event=tag+ type=raw,value=${{ github.sha }}+ type=raw,value=latest,enable={{is_default_branch}}+ type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }}++ - name: Build and push Node image+ uses: docker/build-push-action@v6+ with:+ context: .+ file: Dockerfile.sam-node+ platforms: linux/amd64,linux/arm64+ push: true+ tags: ${{ steps.meta-node.outputs.tags }}+ labels: ${{ steps.meta-node.outputs.labels }}++ deploy:+ name: Deploy to GKE+ runs-on: ubuntu-latest+ needs: publish+ # Dynamically select the GitHub Environment based on the trigger+ environment: ${{ github.ref_type == 'tag' && 'hub' || 'bananas' }}+ permissions:+ contents: 'read'+ id-token: 'write'++ steps:+ - name: Checkout code+ uses: actions/checkout@v4++ - name: Determine Image Tag+ run: |+ if [[ "${{ github.ref_type }}" == "tag" ]]; then+ echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV+ else+ echo "IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV+ fi++ - name: Google Auth+ uses: google-github-actions/auth@v2+ with:+ workload_identity_provider: ${{ vars.WIF_PROVIDER_NAME }}+ service_account: ${{ vars.SERVICE_ACCOUNT_EMAIL }}++ - name: Set up GKE credentials+ uses: google-github-actions/get-gke-credentials@v2+ with:+ cluster_name: ${{ vars.CLUSTER_NAME }}+ location: ${{ vars.CLUSTER_REGION }}++ - name: Prepare Namespaces+ run: |+ export ENV_NAME="${{ vars.ENV_NAME }}"+ export NAMESPACE="sam-${ENV_NAME}"+ export CANARY_NAMESPACE="sam-canary-${ENV_NAME}"++ kubectl create namespace ${NAMESPACE} --dry-run=client -o yaml | kubectl apply -f -+ kubectl create namespace ${CANARY_NAMESPACE} --dry-run=client -o yaml | kubectl apply -f -++ - name: Deploy Hub+ run: |+ sudo apt-get install -y gettext-base++ export ENV_NAME="${{ vars.ENV_NAME }}"+ export LOAD_BALANCER_IP="${{ vars.LOAD_BALANCER_IP }}"+ export EXTERNAL_MULTIADDR="${{ vars.EXTERNAL_MULTIADDR }}"+ export NAMESPACE="sam-${ENV_NAME}"+ export IMAGE_TAG="${{ env.IMAGE_TAG }}"++ envsubst < .github/k8s/sam-hub-template.yaml | kubectl apply -f -++ kubectl rollout status deployment/sam-hub-${ENV_NAME} -n ${NAMESPACE} --timeout=120s || {+ echo "Hub Deployment failed! Rolling back..."+ kubectl rollout undo deployment/sam-hub-${ENV_NAME} -n ${NAMESPACE}+ kubectl rollout status deployment/sam-hub-${ENV_NAME} -n ${NAMESPACE}+ exit 1+ }++ - name: Deploy Canaries+ run: |+ export ENV_NAME="${{ vars.ENV_NAME }}"+ export CANARY_NAMESPACE="sam-canary-${ENV_NAME}"+ export IMAGE_TAG="${{ env.IMAGE_TAG }}"++ envsubst < .github/k8s/sam-canary-template.yaml | kubectl apply -f -++ kubectl rollout status deployment/sam-canary-${ENV_NAME} -n ${CANARY_NAMESPACE} --timeout=120s || {+ echo "Canary Deployment failed! Rolling back..."+ kubectl rollout undo deployment/sam-canary-${ENV_NAME} -n ${CANARY_NAMESPACE}+ kubectl rollout status deployment/sam-canary-${ENV_NAME} -n ${CANARY_NAMESPACE}+ exit 1+ }diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yamldeleted file mode 100644index e7f871ef..00000000--- a/.github/workflows/release.yaml+++ /dev/null@@ -1,85 +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-#-# https://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.--name: release--on:- push:- tags:- - 'v*'- workflow_dispatch:--env:- REGISTRY: ghcr.io--jobs:- publish:- name: publish- runs-on: ubuntu-latest- permissions:- packages: write- timeout-minutes: 100-- steps:- - name: Check out code- uses: actions/checkout@v6-- - name: Set up QEMU- uses: docker/setup-qemu-action@v4-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v4-- - name: Log in to the Container registry- uses: docker/login-action@v4- with:- registry: ${{ env.REGISTRY }}- username: ${{ github.actor }}- password: ${{ secrets.GITHUB_TOKEN }}-- - name: Extract metadata for Hub- id: meta-hub- uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf- with:- images: ${{ env.REGISTRY }}/google/sam-hub-- - name: Build and push Hub image- uses: docker/build-push-action@v7- with:- context: .- file: Dockerfile.sam-hub- platforms: linux/amd64,linux/arm64- push: true- tags: |- ${{ steps.meta-hub.outputs.tags }}- ${{ env.REGISTRY }}/google/sam-hub:stable- labels: ${{ steps.meta-hub.outputs.labels }}-- - name: Extract metadata for Node- id: meta-node- uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf- with:- images: ${{ env.REGISTRY }}/google/sam-node-- - name: Build and push Node image- uses: docker/build-push-action@v7- with:- context: .- file: Dockerfile.sam-node- platforms: linux/amd64,linux/arm64- push: true- tags: |- ${{ steps.meta-node.outputs.tags }}- ${{ env.REGISTRY }}/google/sam-node:stable- labels: ${{ steps.meta-node.outputs.labels }}\ No newline at end of file