Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
Add GCP VM provisioning with GCS binary injection and bulk scale out
Antonio Ojea233f50d1e718
diff --git a/scripts/cloud-init.yaml b/scripts/cloud-init.yamlnew file mode 100644index 00000000..ff0224f5--- /dev/null+++ b/scripts/cloud-init.yaml@@ -0,0 +1,48 @@+#cloud-config+package_update: true+package_upgrade: true+packages:+ - curl+ - wget+ - git+ - iptables+ - iproute2+ - socat+ - jq+ - build-essential+ - docker.io+ - acl++runcmd:+ # Ensure KVM permissions allow execution+ - chmod 0666 /dev/kvm++ # Install Firecracker v1.16.1+ - curl -LO https://github.com/firecracker-microvm/firecracker/releases/download/v1.16.1/firecracker-v1.16.1-x86_64.tgz+ - tar -xzf firecracker-v1.16.1-x86_64.tgz+ - mv release-v1.16.1-x86_64/firecracker-v1.16.1-x86_64 /usr/local/bin/firecracker+ - chmod +x /usr/local/bin/firecracker+ - rm -rf release-v1.16.1-x86_64 firecracker-v1.16.1-x86_64.tgz++ # Enable IP forwarding (just in case we need it for TAP/NAT later)+ - sysctl -w net.ipv4.ip_forward=1+ - echo "net.ipv4.ip_forward=1" >> /etc/sysctl.d/99-ipforward.conf++ # Install SAM Mesh binaries+ # Check if custom binaries were injected via GCP metadata (GCS URL)+ - |+ BIN_URL=$(curl -s -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/sam-binaries-url" || true)++ if [ -n "$BIN_URL" ] && [ "$BIN_URL" != "null" ]; then+ echo "Found custom binaries URL: $BIN_URL. Downloading from GCS..."+ # Use gcloud storage (pre-installed on Google OS images) to download via the attached service account+ gcloud storage cp "$BIN_URL/sam-node" /usr/local/bin/+ gcloud storage cp "$BIN_URL/sam-box" /usr/local/bin/+ chmod +x /usr/local/bin/sam-*+ else+ echo "No custom binaries specified. Installing latest release from github..."+ export SAM_INSTALL_DIR=/usr/local/bin+ curl -sL https://sam-mesh.dev/install.sh | bash+ fi++ - echo "SAM Host cloud-init bootstrap finished successfully."diff --git a/scripts/provision-scale-vm.sh b/scripts/provision-scale-vm.shnew file mode 100755index 00000000..460e5502--- /dev/null+++ b/scripts/provision-scale-vm.sh@@ -0,0 +1,114 @@+#!/bin/bash+set -e++VM_NAME_PREFIX="sam-minions"+ZONE="us-central1-a"+PROJECT="ipv6-project-379110"+GCS_URL=""+COUNT=1++while [[ "$#" -gt 0 ]]; do+ case $1 in+ --prefix) VM_NAME_PREFIX="$2"; shift ;;+ --zone) ZONE="$2"; shift ;;+ --project) PROJECT="$2"; shift ;;+ --local-binaries) GCS_URL="$2"; shift ;;+ --count) COUNT="$2"; shift ;;+ *) echo "Unknown parameter passed: $1"; exit 1 ;;+ esac+ shift+done++METADATA="enable-osconfig=TRUE"++if [ -n "$GCS_URL" ]; then+ echo "Building local binaries for injection..."+ # Make sure we build for Linux x86_64 since the VM is Debian x86_64+ GOOS=linux GOARCH=amd64 go build -o /tmp/sam-node ./cmd/sam-node+ GOOS=linux GOARCH=amd64 go build -o /tmp/sam-box ./cmd/sam-box++ echo "Uploading binaries to GCS: $GCS_URL"+ gcloud storage cp /tmp/sam-node "$GCS_URL/sam-node"+ gcloud storage cp /tmp/sam-box "$GCS_URL/sam-box"++ METADATA="enable-osconfig=TRUE,sam-binaries-url=$GCS_URL"+fi++echo "Provisioning $COUNT GCP Scale Experiment VM(s) with prefix '${VM_NAME_PREFIX}' in ${ZONE} (${PROJECT})..."++if [ "$COUNT" -eq 1 ]; then+ # Create a single instance+ gcloud beta compute instances create "${VM_NAME_PREFIX}-1" \+ --project="${PROJECT}" \+ --zone="${ZONE}" \+ --machine-type=n2-standard-64 \+ --enable-nested-virtualization \+ --min-cpu-platform="Intel Ice Lake" \+ --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default \+ --metadata="${METADATA}" \+ --metadata-from-file=user-data=scripts/cloud-init.yaml \+ --no-restart-on-failure \+ --maintenance-policy=TERMINATE \+ --provisioning-model=SPOT \+ --preemption-notice-duration=0s \+ --instance-termination-action=STOP \+ --service-account=628944397724-compute@developer.gserviceaccount.com \+ --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/trace.append \+ --tags=http-server,https-server,lb-health-check \+ --create-disk=auto-delete=yes,boot=yes,image=projects/debian-cloud/global/images/debian-13-trixie-v20260817,mode=rw,size=250,type=pd-ssd \+ --no-shielded-secure-boot \+ --shielded-vtpm \+ --shielded-integrity-monitoring \+ --labels=goog-ops-agent-policy=v2-template-1-7-0,goog-ec-src=vm_add-gcloud \+ --reservation-affinity=none+else+ # Bulk create multiple instances+ gcloud beta compute instances bulk create \+ --name-pattern="${VM_NAME_PREFIX}-#" \+ --count="${COUNT}" \+ --project="${PROJECT}" \+ --zone="${ZONE}" \+ --machine-type=n2-standard-64 \+ --enable-nested-virtualization \+ --min-cpu-platform="Intel Ice Lake" \+ --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default \+ --metadata="${METADATA}" \+ --metadata-from-file=user-data=scripts/cloud-init.yaml \+ --no-restart-on-failure \+ --maintenance-policy=TERMINATE \+ --provisioning-model=SPOT \+ --preemption-notice-duration=0s \+ --instance-termination-action=STOP \+ --service-account=628944397724-compute@developer.gserviceaccount.com \+ --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/trace.append \+ --tags=http-server,https-server,lb-health-check \+ --create-disk=auto-delete=yes,boot=yes,image=projects/debian-cloud/global/images/debian-13-trixie-v20260817,mode=rw,size=250,type=pd-ssd \+ --no-shielded-secure-boot \+ --shielded-vtpm \+ --shielded-integrity-monitoring \+ --labels=goog-ops-agent-policy=v2-template-1-7-0,goog-ec-src=vm_add-gcloud \+ --reservation-affinity=none+fi++echo "Successfully triggered VM creation. Applying Ops Agent policy..."++# Apply Ops Agent Policy for host-level monitoring+cat <<EOF > /tmp/ops-agent-config.yaml+agentsRule:+ packageState: installed+ version: latest+instanceFilter:+ inclusionLabels:+ - labels:+ goog-ops-agent-policy: v2-template-1-7-0+EOF++gcloud compute instances ops-agents policies create "goog-ops-agent-v2-template-1-7-0-${ZONE}" \+ --project="${PROJECT}" \+ --zone="${ZONE}" \+ --file=/tmp/ops-agent-config.yaml || echo "Warning: Ops Agent policy creation returned an error (it might already exist)."++echo ""+echo "Done! The VM ${VM_NAME} is booting. cloud-init is running in the background to install Firecracker, Go, and sam-box."+echo "You can view the cloud-init logs by SSHing into the VM and running:"+echo " sudo tail -f /var/log/cloud-init-output.log"