Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
Update sam-hub to use Gateway API, add bootstrap dnsaddr, and restrict HTTP prefixes
Antonio Ojea8d97328aebb5
diff --git a/.github/k8s/cert-sync-cronjob-template.yaml b/.github/k8s/cert-sync-cronjob-template.yamldeleted file mode 100644index da125227..00000000--- a/.github/k8s/cert-sync-cronjob-template.yaml+++ /dev/null@@ -1,84 +0,0 @@-apiVersion: v1-kind: ServiceAccount-metadata:- name: cert-sync-sa- namespace: sam-hub-----apiVersion: rbac.authorization.k8s.io/v1-kind: Role-metadata:- name: cert-reader- namespace: sam-${ENV_NAME}-rules:-- apiGroups: [""]- resources: ["secrets"]- resourceNames: ["hub-sam-mesh-tls"]- verbs: ["get"]-----apiVersion: rbac.authorization.k8s.io/v1-kind: RoleBinding-metadata:- name: cert-sync-read-binding- namespace: sam-${ENV_NAME}-roleRef:- apiGroup: rbac.authorization.k8s.io- kind: Role- name: cert-reader-subjects:-- kind: ServiceAccount- name: cert-sync-sa- namespace: sam-hub-----apiVersion: rbac.authorization.k8s.io/v1-kind: Role-metadata:- name: cert-writer- namespace: sam-hub-rules:-- apiGroups: [""]- resources: ["secrets"]- verbs: ["get", "create", "delete"]-----apiVersion: rbac.authorization.k8s.io/v1-kind: RoleBinding-metadata:- name: cert-sync-write-binding- namespace: sam-hub-roleRef:- apiGroup: rbac.authorization.k8s.io- kind: Role- name: cert-writer-subjects:-- kind: ServiceAccount- name: cert-sync-sa- namespace: sam-hub-----apiVersion: batch/v1-kind: CronJob-metadata:- name: cert-sync-cronjob- namespace: sam-hub-spec:- schedule: "0 0 * * *" # Run daily at midnight- concurrencyPolicy: Forbid- successfulJobsHistoryLimit: 1- failedJobsHistoryLimit: 3- jobTemplate:- spec:- template:- spec:- serviceAccountName: cert-sync-sa- restartPolicy: OnFailure- containers:- - name: sync-agent- image: bitnami/kubectl:latest- command:- - /bin/sh- - -c- - |- echo "Fetching latest wildcard TLS secret from sam-${ENV_NAME} namespace..."- kubectl delete secret hub-sam-mesh-tls -n sam-hub --ignore-not-found- kubectl get secret hub-sam-mesh-tls -n sam-${ENV_NAME} -o yaml | \- sed "s/namespace: sam-${ENV_NAME}/namespace: sam-hub/" | \- kubectl create -f -- echo "Certificate successfully synchronized!"diff --git a/.github/k8s/google-public-ca-issuer-template.yaml b/.github/k8s/google-public-ca-issuer-template.yamldeleted file mode 100644index f28add9a..00000000--- a/.github/k8s/google-public-ca-issuer-template.yaml+++ /dev/null@@ -1,20 +0,0 @@-apiVersion: cert-manager.io/v1-kind: Issuer-metadata:- name: google-public-ca-issuer- namespace: ${NAMESPACE}-spec:- acme:- server: https://dv.acme-v02.api.pki.goog/directory- email: "${ACME_EMAIL}"- privateKeySecretRef:- name: google-ca-account-key- externalAccountBinding:- keyID: "${EAB_KEY_ID}"- keySecretRef:- name: google-ca-eab-secret- key: secret- solvers:- - dns01:- cloudDNS:- project: ${GCP_PROJECT_ID}diff --git a/.github/k8s/sam-hub-template.yaml b/.github/k8s/sam-hub-template.yamlindex b1c16651..68729140 100644--- a/.github/k8s/sam-hub-template.yaml+++ b/.github/k8s/sam-hub-template.yaml@@ -6,6 +6,10 @@ metadata:spec:clusterIP: Noneports:+ - port: 9090+ targetPort: 9090+ protocol: TCP+ name: http- port: 4501targetPort: 4501protocol: TCP@@ -79,6 +83,7 @@ spec:- "--external-multiaddr=/ip4/$(HOST_IP)/tcp/4501"- "--external-multiaddr=/ip4/$(HOST_IP)/udp/4501/quic-v1"- "--external-multiaddr=/ip4/$(HOST_IP)/tcp/4501/wss"+ - "--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.@@ -132,3 +137,66 @@ spec:interval: 30spath: /metricsscheme: 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/.github/k8s/wildcard-cert-template.yaml b/.github/k8s/wildcard-cert-template.yamldeleted file mode 100644index ceec88e3..00000000--- a/.github/k8s/wildcard-cert-template.yaml+++ /dev/null@@ -1,14 +0,0 @@-apiVersion: cert-manager.io/v1-kind: Certificate-metadata:- name: hub-sam-mesh-cert- namespace: ${NAMESPACE}-spec:- secretName: hub-sam-mesh-tls- issuerRef:- name: google-public-ca-issuer- kind: Issuer- commonName: "*.sam-mesh.dev"- dnsNames:- - "*.sam-mesh.dev"- - "sam-mesh.dev"diff --git a/cmd/sam-hub/server.go b/cmd/sam-hub/server.goindex 0082b29b..b510b6e3 100644--- a/cmd/sam-hub/server.go+++ b/cmd/sam-hub/server.go@@ -32,6 +32,10 @@ func handleRegisterHTTP(h *Hub) http.HandlerFunc {http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)return}+ if r.URL.Path != "/register" {+ http.NotFound(w, r)+ return+ }body, err := io.ReadAll(r.Body)if err != nil {@@ -111,6 +115,10 @@ func handleInfoHTTP(h *Hub) http.HandlerFunc {http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)return}+ if r.URL.Path != "/info" {+ http.NotFound(w, r)+ return+ }// Find the OIDC issuer deterministically by sorting the map keysissuer := ""