Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
kind: deploy sam infrastructure only, drop the mesh-config node templating
Tomas Tormofe43d8de1a71
diff --git a/development/kind/kind-config.yaml b/development/kind/kind-config.yamlindex 80906475..070caa0d 100644--- a/development/kind/kind-config.yaml+++ b/development/kind/kind-config.yaml@@ -6,8 +6,3 @@ nodes:labels:sam-role: control-plane- role: worker- labels:- sam-role: node-a- - role: worker- labels:- sam-role: node-bdiff --git a/development/kind/mesh-config.e2e.yaml b/development/kind/mesh-config.e2e.yamldeleted file mode 100644index 86753d6c..00000000--- a/development/kind/mesh-config.e2e.yaml+++ /dev/null@@ -1,4 +0,0 @@-# E2E mesh layout: pins calc-mcp so the kind-mesh-e2e check can discover-# mcp://calculator/add. Select it with MESH_CONFIG=development/kind/mesh-config.e2e.yaml.-node-a:-node-b: calc-mcpdiff --git a/development/kind/mesh-config.yaml b/development/kind/mesh-config.yamldeleted file mode 100644index 58430ebb..00000000--- a/development/kind/mesh-config.yaml+++ /dev/null@@ -1,8 +0,0 @@-# node -> service. A blank value means a bare node (no service, e.g. a caller).-# Set a value to host a service on that node; the value is a folder path under-# development/examples/, e.g:-# node-a: calc-mcp-# node-b: code-reviewer-pool/reviewer-# All nodes ship bare by default — assign services to suit what you're testing.-node-a:-node-b:diff --git a/development/kind/node.template.yaml b/development/kind/node.template.yamldeleted file mode 100644index c7e8b445..00000000--- a/development/kind/node.template.yaml+++ /dev/null@@ -1,55 +0,0 @@-apiVersion: v1-kind: ServiceAccount-metadata:- name: ${NODE}-sa- namespace: ${NAMESPACE}-----apiVersion: apps/v1-kind: Deployment-metadata:- name: ${NODE}- namespace: ${NAMESPACE}-spec:- replicas: 1- selector:- matchLabels:- app: ${NODE}- template:- metadata:- labels:- app: ${NODE}- spec:- nodeSelector:- sam-role: ${NODE}- serviceAccountName: ${NODE}-sa- containers:- - name: sam-node- image: sam-node:${IMAGE_TAG}- imagePullPolicy: IfNotPresent- env:- - name: SAM_API_TOKEN- value: "devtoken"- args:- - "run"- - "--control-plane=${CONTROL_PLANE_URL}"- - "--jwt-path=/var/run/secrets/tokens/sam-token"- - "--bind-addr=0.0.0.0:8080"- - "--discovery-interval=200ms"-${CONFIG_ARG}- ports:- - { containerPort: 8080, name: mcp, protocol: TCP }- volumeMounts:- - name: sam-token- mountPath: /var/run/secrets/tokens- readOnly: true-${CONFIG_MOUNT}-${SIDECAR}- volumes:- - name: sam-token- projected:- sources:- - serviceAccountToken:- path: sam-token- expirationSeconds: 3600- audience: sam-mesh-audience-${CONFIG_VOLUME}diff --git a/development/kind/run-local-node.sh b/development/kind/run-local-node.shindex 469d746b..5814ffae 100755--- a/development/kind/run-local-node.sh+++ b/development/kind/run-local-node.sh@@ -2,7 +2,7 @@# Enroll a locally-built ./bin/sam-node into the kind mesh the way a real external node joins:# a bootstrap token over the control plane's gateway address, peer traffic through the router's# node-IP multiaddrs. Extra args pass through, e.g. to host a service:-# ARGS="--config development/examples/calc-mcp/sam-node-config.yaml"+# ARGS="--config my-node.yaml"set -euo pipefailCLUSTER="sam-kind"diff --git a/development/kind/run.sh b/development/kind/run.shindex 96dc8df3..424ec42f 100755--- a/development/kind/run.sh+++ b/development/kind/run.sh@@ -1,7 +1,7 @@#!/usr/bin/env bash-# Kind dev mesh: a control plane and router plus the nodes from mesh-config.yaml, each pinned to its-# own k8s node, with live per-pod logs in named tmux panes. Control plane, console and Dex are reached-# over Gateway API LoadBalancer addresses from cloud-provider-kind (started here); the router at its node IP.+# Kind dev mesh: control plane, router, console and Dex, with live per-pod logs in named tmux+# panes. No sam-nodes are deployed — put services on the mesh with charts/sam-node (see the+# epilogue below) or enroll a local node. Gateway addresses come from cloud-provider-kind.set -euo pipefailCLUSTER="sam-kind"@@ -24,7 +24,7 @@ PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"cd "${PROJECT_ROOT}"check_prereqs() {- local bins=(kind kubectl docker jq envsubst awk)+ local bins=(kind kubectl docker jq envsubst)[[ "${1:-}" != "-s" ]] && bins+=(tmux)for bin in "${bins[@]}"; docommand -v "$bin" >/dev/null 2>&1 || { echo "missing prerequisite: $bin" >&2; exit 1; }@@ -122,30 +122,6 @@ apply_dex() {| kubectl --context "${KCTX}" -n "${NAMESPACE}" apply -f -}-render_and_apply() {- local node="$1" svc="$2"- local CONFIG_ARG="" CONFIG_MOUNT="" SIDECAR="" CONFIG_VOLUME=""- if [[ -n "$svc" ]]; then- local dir="${PROJECT_ROOT}/development/examples/${svc}"- local name="$(basename "$svc")"- [[ -d "$dir" ]] || { echo "service '${svc}' (node ${node}) not found in development/examples/" >&2; exit 1; }- echo "Building service image ${name}:${IMAGE_TAG}…"- docker build -t "${name}:${IMAGE_TAG}" "$dir"- kind load docker-image --name "${CLUSTER}" "${name}:${IMAGE_TAG}"- kubectl --context "${KCTX}" -n "${NAMESPACE}" create configmap "${node}-config" \- --from-file=sam-node.yaml="${dir}/sam-node-config.yaml" \- --dry-run=client -o yaml | kubectl --context "${KCTX}" apply -f -- CONFIG_ARG=' - "--config=/etc/sam/sam-node.yaml"'- CONFIG_MOUNT=$' - name: config\n mountPath: /etc/sam'- SIDECAR=$' - name: '"${name}"$'\n image: '"${name}:${IMAGE_TAG}"$'\n imagePullPolicy: IfNotPresent'- CONFIG_VOLUME=$' - name: config\n configMap:\n name: '"${node}-config"- fi- NODE="$node" CONTROL_PLANE_URL="$CONTROL_PLANE_URL" CONFIG_ARG="$CONFIG_ARG" CONFIG_MOUNT="$CONFIG_MOUNT" SIDECAR="$SIDECAR" CONFIG_VOLUME="$CONFIG_VOLUME" \- envsubst '${NODE} ${NAMESPACE} ${CONTROL_PLANE_URL} ${IMAGE_TAG} ${CONFIG_ARG} ${CONFIG_MOUNT} ${SIDECAR} ${CONFIG_VOLUME}' \- < "${SCRIPT_DIR}/node.template.yaml" | kubectl --context "${KCTX}" apply -f ---}-# logs: $1 = pane name (printed in-pane and set as the pane title); $2 = logs target.logs() { echo "printf '\\033[1;36m==== %s ====\\033[0m\\n' '$1'; kubectl --context ${KCTX} -n ${NAMESPACE} logs -f $2; echo; echo '[$1 pane exited; press enter]'; read"; }@@ -157,15 +133,11 @@ show_cluster_logs() {tmuxs new-session -d -s "${SESSION}" -n mesh "$(logs control-plane 'deploy/sam-mesh-control-plane')" \; set -t "${SESSION}" destroy-unattached offtmuxs split-window -t "${SESSION}:0" "$(logs router 'statefulset/sam-mesh-router')"- for node in "${NODES[@]}"; do- tmuxs split-window -t "${SESSION}:0" "$(logs "$node" "deploy/${node} -c sam-node")"- tmuxs select-layout -t "${SESSION}:0" tiled- donetmuxs set-option -t "${SESSION}" -g pane-border-status toptmuxs set-option -t "${SESSION}" -g pane-border-format ' #{pane_title} '- # Title the tmux panes in creation order: control-plane, router, then the nodes.- titles=(control-plane router "${NODES[@]}")+ # Title the tmux panes in creation order: control-plane, router.+ titles=(control-plane router)i=0for pane in $(tmuxs list-panes -t "${SESSION}:0" -F '#{pane_id}'); dotmuxs select-pane -t "$pane" -T "${titles[$i]}"@@ -176,15 +148,6 @@ show_cluster_logs() {tmuxs attach-session -t "${SESSION}"}-# Read the node -> service assignment into NODE_LINES (each line:-# "<node> <service-or-empty>") and the NODES array. Defaults to mesh-config.yaml;-# override with MESH_CONFIG (e.g. the e2e lane pins calc-mcp via mesh-config.e2e.yaml).-read_mesh_nodes() {- mapfile -t NODE_LINES < <(awk -F: '/^[A-Za-z0-9_-]+:/{n=$1; s=$2; gsub(/[[:space:]]/,"",n); gsub(/[[:space:]]/,"",s); print n, s}' "${MESH_CONFIG:-${SCRIPT_DIR}/mesh-config.yaml}")- NODES=()- for line in "${NODE_LINES[@]}"; do NODES+=("${line%% *}"); done-}-### MAIN ###@@ -195,7 +158,6 @@ if [[ $# -gt 0 && "$1" != "-s" && "$1" != "-l" && "$1" != "-d" ]]; thenfiif [[ "${1:-}" == "-l" ]]; then- read_mesh_nodesshow_cluster_logsexit 0fi@@ -218,8 +180,6 @@ make docker-build-control-plane docker-build-router docker-build-node docker-buiecho "== Loading sam images into kind =="kind load docker-image --name "${CLUSTER}" "sam-control-plane:${IMAGE_TAG}" "sam-router:${IMAGE_TAG}" "sam-node:${IMAGE_TAG}" "sam-console:${IMAGE_TAG}"-read_mesh_nodes-# Apply the control plane and router, and wait until they accept connectionsISSUER="$(kubectl --context "${KCTX}" get --raw /.well-known/openid-configuration | jq -r .issuer)"[[ -n "$ISSUER" ]] || { echo "could not determine cluster OIDC issuer" >&2; exit 1; }@@ -232,8 +192,8 @@ CONTROL_PLANE_ISSUERS="${ISSUER}"# match Dex's static client.ALLOWED_AUDIENCES="sam-console,sam-mesh-audience,sam-control-plane-audience"-# Only the node template's envsubst reads these from the environment.-export NAMESPACE IMAGE_TAG+# 00-namespace-rbac.yaml's envsubst reads this from the environment.+export NAMESPACEecho "== Applying namespace and RBAC cluster rules =="envsubst '${NAMESPACE}' < "${SCRIPT_DIR}/00-namespace-rbac.yaml" | kubectl --context "${KCTX}" apply -f -@@ -300,24 +260,18 @@ echo "== Restarting the console with the final issuer =="kubectl --context "${KCTX}" -n "${NAMESPACE}" rollout restart deployment/sam-mesh-consolekubectl --context "${KCTX}" -n "${NAMESPACE}" rollout status deployment/sam-mesh-console --timeout=180s--echo "== Applying sam-nodes =="-for line in "${NODE_LINES[@]}"; do- node="${line%% *}"; svc="${line#* }"; [[ "$svc" == "$node" ]] && svc=""- render_and_apply "$node" "$svc"-done--echo "== Waiting for sam-nodes =="-for node in "${NODES[@]}"; do- kubectl --context "${KCTX}" -n "${NAMESPACE}" wait --for=condition=available --timeout=180s "deployment/${node}"-done-echoecho "Mesh up."echo " console: ${CONSOLE_URL}"echo " control plane: http://${MAIN_IP}"echo " dex: ${OIDC_ISSUER}"echo+echo "To put a service on the mesh, deploy an example with charts/sam-node:"+echo " docker build -t calc-mcp:local development/examples/calc-mcp"+echo " kind load docker-image --name ${CLUSTER} calc-mcp:local"+echo " ${HELM} --kube-context ${KCTX} -n ${NAMESPACE} install calc-mcp charts/sam-node \\"+echo " -f development/kind/sam-node.values.yaml -f development/examples/calc-mcp/values.yaml"+echoecho "To drive the mesh, enroll a local node in another shell (it stays in the foreground):"echo " make build && make kind-local-node"echo "then call its MCP API on 127.0.0.1:9099:"