Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dist/
coverage.*
mobile/agentmesh-node-app/build/
sdk/js/build/
internal/webapp/public/sdk/
site/public/
site/resources/
rootfs.ext4
Expand Down
83 changes: 83 additions & 0 deletions .github/k8s/agentmesh-webapp-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: v1
kind: Service
metadata:
name: agentmesh-webapp-${ENV_NAME}
namespace: ${NAMESPACE}
spec:
ports:
- port: 8082
targetPort: 8082
protocol: TCP
name: http
selector:
app: agentmesh-webapp-${ENV_NAME}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: agentmesh-webapp-${ENV_NAME}
namespace: ${NAMESPACE}
spec:
replicas: 1
selector:
matchLabels:
app: agentmesh-webapp-${ENV_NAME}
template:
metadata:
labels:
app: agentmesh-webapp-${ENV_NAME}
spec:
containers:
- name: agentmesh-webapp
image: ghcr.io/google/agentmesh-webapp:${IMAGE_TAG}
imagePullPolicy: IfNotPresent
args:
- "--bind-addr=:8082"
ports:
- containerPort: 8082
readinessProbe:
httpGet:
path: /
port: 8082
resources:
requests:
cpu: 10m
memory: 32Mi
---
# The page needs no host of its own: it shares the testnet's Gateway, host and
# certificate under /node/, and the prefix is stripped before the web app sees it.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: agentmesh-webapp-route-${ENV_NAME}
namespace: ${NAMESPACE}
spec:
parentRefs:
- name: sam-control-plane-gateway-${ENV_NAME}
hostnames:
- "${ENV_NAME}.sam-mesh.dev"
rules:
- matches:
- path:
type: Exact
value: /node
filters:
- type: RequestRedirect
requestRedirect:
path:
type: ReplaceFullPath
replaceFullPath: /node/
statusCode: 302
- matches:
- path:
type: PathPrefix
value: /node/
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /
backendRefs:
- name: agentmesh-webapp-${ENV_NAME}
port: 8082
6 changes: 6 additions & 0 deletions .github/k8s/dex-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ data:
web:
# Serve plain HTTP locally; the GKE Ingress handles HTTPS termination
http: 0.0.0.0:5556
# The web app at /node/ reads discovery and trades its sign-in code from the browser.
allowedOrigins:
- 'https://bananas.sam-mesh.dev'
- 'https://hub.sam-mesh.dev'

oauth2:
grantTypes:
Expand Down Expand Up @@ -54,6 +58,8 @@ data:
- 'http://localhost/callback'
- 'https://bananas.sam-mesh.dev/console/auth/callback'
- 'https://hub.sam-mesh.dev/console/auth/callback'
- 'https://bananas.sam-mesh.dev/node/'
- 'https://hub.sam-mesh.dev/node/'
- 'https://auth.sam-mesh.dev/device/callback'
- 'urn:ietf:wg:oauth:2.0:oob'
- '/device/callback'
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ jobs:
tags: ${{ steps.meta-console.outputs.tags }}
labels: ${{ steps.meta-console.outputs.labels }}

- name: Extract metadata for agentmesh-webapp
id: meta-webapp
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.REGISTRY }}/google/agentmesh-webapp
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 agentmesh-webapp image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
file: Dockerfile.agentmesh-webapp
build-args: VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
platforms: ${{ github.ref_type == 'tag' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: true
tags: ${{ steps.meta-webapp.outputs.tags }}
labels: ${{ steps.meta-webapp.outputs.labels }}

- name: Extract metadata for agentmesh-one
id: meta-agentmesh-one
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
Expand Down Expand Up @@ -404,6 +427,7 @@ jobs:
envsubst '${ENV_NAME} ${NAMESPACE} ${GCP_PROJECT_ID} ${CLUSTER_NAME} ${CLUSTER_REGION} ${IMAGE_TAG} ${NODE_RETENTION}' < .github/k8s/agentmesh-control-plane-template.yaml | kubectl apply -f -
envsubst '${ENV_NAME} ${NAMESPACE} ${GCP_PROJECT_ID} ${CLUSTER_NAME} ${CLUSTER_REGION} ${IMAGE_TAG} ${ROUTER_REPLICAS} ${ROUTER_HIGH_WATERMARK}' < .github/k8s/agentmesh-router-template.yaml | kubectl apply -f -
envsubst '${ENV_NAME} ${NAMESPACE} ${GCP_PROJECT_ID} ${CLUSTER_NAME} ${CLUSTER_REGION} ${IMAGE_TAG}' < .github/k8s/agentmesh-console-template.yaml | kubectl apply -f -
envsubst '${ENV_NAME} ${NAMESPACE} ${IMAGE_TAG}' < .github/k8s/agentmesh-webapp-template.yaml | kubectl apply -f -
envsubst '${ENV_NAME} ${NAMESPACE} ${GCP_PROJECT_ID}' < .github/k8s/dns-sync-cronjob-template.yaml | kubectl apply -f -
# Managed Prometheus ships with GKE; a cluster without it should not block the mesh rollout.
if kubectl get crd podmonitorings.monitoring.googleapis.com >/dev/null 2>&1; then
Expand Down Expand Up @@ -467,6 +491,12 @@ jobs:
exit 1
}

kubectl rollout status deployment/agentmesh-webapp-${ENV_NAME} -n ${NAMESPACE} --timeout=120s || {
echo "Web app Deployment failed!"
print_rollout_diagnostics "${NAMESPACE}" "deployment/agentmesh-webapp-${ENV_NAME}" "app=agentmesh-webapp-${ENV_NAME}"
exit 1
}

# Each router is held 90s after it is ready (minReadySeconds) so
# members re-attach before the next one goes, which with its
# startup is about two minutes a router. The wait follows the
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ jobs:
with:
node-version: "22"
cache: npm
cache-dependency-path: tests/ui/package-lock.json
cache-dependency-path: |
tests/ui/package-lock.json
sdk/js/package-lock.json

- name: Run console UI smoke test
run: make ui-test
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ dist/
/agentmesh-box
/agentmesh-router
/agentmesh-console
/agentmesh-webapp

/internal/webapp/public/sdk/

# Playwright console UI tests
node_modules/
Expand Down
5 changes: 3 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version: 2
project_name: agentmesh
# Deliberately not released: agentmesh-bench (a measurement instrument for people
# working on the mesh, built from the repo, not something operators install)
# and chaos-agent (a Python dev tool).
# working on the mesh, built from the repo, not something operators install),
# chaos-agent (a Python dev tool) and agentmesh-webapp (an image and a Helm
# chart only).
builds:
- id: agentmesh-node
main: ./cmd/agentmesh-node
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile.agentmesh-webapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# The web app embeds the SDK bundle; JavaScript and wasm are the same on every platform.
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim@sha256:c3de60bf2f9dd0ac6370e6117950ff62d6e339527e7472301c9c78a017978392 AS sdk-bundle
WORKDIR /src/sdk/js
COPY sdk/js/package.json sdk/js/package-lock.json sdk/js/.npmrc ./
RUN npm ci --no-fund --no-audit
COPY sdk/js/ ./
RUN npm run build && npm run bundle:app

FROM --platform=$BUILDPLATFORM golang:1.27.4@sha256:205c7636d74e0ffbe3d007162df7d74f859f5a8c8322dfb9f907977686c126cf AS builder

WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download

COPY . .
COPY --from=sdk-bundle /src/internal/webapp/public/sdk/ internal/webapp/public/sdk/
ARG VERSION=devel
ARG TARGETOS=linux
ARG TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -buildvcs=false -ldflags="-X github.com/google/agentmesh/internal/version.Version=${VERSION}" -o /bin/agentmesh-webapp ./cmd/agentmesh-webapp

FROM gcr.io/distroless/static:nonroot@sha256:8ce6dd87e9823c5b48dcfb2c8604714ccb351ce59607327bcc4957448da279b5

COPY --from=builder --chown=nonroot:nonroot /bin/agentmesh-webapp /usr/local/bin/agentmesh-webapp

USER nonroot:nonroot
EXPOSE 8082
ENTRYPOINT ["/usr/local/bin/agentmesh-webapp"]
38 changes: 33 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ build:
go build -v -ldflags "$(VERSION_LDFLAGS)" -o "$(OUT_DIR)/mcp-client" ./cmd/mcp-client
go build -v -ldflags "$(VERSION_LDFLAGS)" -o "$(OUT_DIR)/agentmesh-bench" ./cmd/agentmesh-bench
go build -v -ldflags "$(VERSION_LDFLAGS)" -o "$(OUT_DIR)/agentmesh-console" ./cmd/agentmesh-console
go build -v -ldflags "$(VERSION_LDFLAGS)" -o "$(OUT_DIR)/agentmesh-webapp" ./cmd/agentmesh-webapp

# The binaries plus the web app agentmesh-webapp embeds, which needs Node.js 22 and npm.
# build runs in the recipe, not as a prerequisite, so make -j cannot embed before the bundle exists.
.PHONY: all
all:
$(MAKE) app
$(MAKE) build

.PHONY: mobile-ffi-host mobile-ffi-android mobile-ffi-android-x86_64 mobile-ffi-ios mobile-ffi mobile-app-apk mobile-app-apk-emulator mobile-app-bundle
mobile-ffi-host:
Expand Down Expand Up @@ -187,8 +194,26 @@ sdk-docs:
sdk-test: sdk-js sdk-python
go test ./tests/integration -run TestNativeSDK -count=1 -v

# The SDK bundle the web app imports; the next go build of agentmesh-webapp embeds it.
# The relay is the recipe's last output, so a failed relay build leaves the bundle out of date.
APP_SDK_BUNDLE := internal/webapp/public/sdk/agentmesh-relay.mjs

.PHONY: app app-test
app: $(APP_SDK_BUNDLE)

$(APP_SDK_BUNDLE): sdk/js/node_modules/.package-lock.json sdk/js/package.json sdk/js/scripts/bundle-browser.mjs \
$(shell find sdk/js/src sdk/js/webapp -name '*.ts' ! -name '*.test.ts') sdk/js/webapp/index.mjs
cd sdk/js && npm run build && npm run bundle:app

sdk/js/node_modules/.package-lock.json: sdk/js/package-lock.json
cd sdk/js && npm ci --no-fund --no-audit

app-test:
node --test internal/webapp/model.test.mjs

.PHONY: ui-test
ui-test: build
ui-test: app-test
$(MAKE) all
chmod +x ./tests/ui/run.sh
./tests/ui/run.sh $(if $(WHAT),--grep "$(WHAT)")

Expand Down Expand Up @@ -235,7 +260,7 @@ helm-lint:
exit 1; \
fi; \
fi; \
$$HELM_BIN lint ./charts/agentmesh && $$HELM_BIN lint ./charts/agentmesh-node --set controlPlaneUrl=http://required-for-lint:8080
$$HELM_BIN lint ./charts/agentmesh && $$HELM_BIN lint ./charts/agentmesh-node --set controlPlaneUrl=http://required-for-lint:8080 && $$HELM_BIN lint ./charts/agentmesh-webapp

# render the chart to bin/chart/ for inspection; pass extra flags via ARGS, e.g. ARGS="--set gateway.enabled=true"
.PHONY: helm-template
Expand All @@ -250,7 +275,7 @@ lint: fmt helm-lint
.PHONY: helm-test
helm-test:
@helm plugin list 2>/dev/null | grep -q '^unittest' || helm plugin install https://github.com/helm-unittest/helm-unittest --version 0.8.2
helm unittest charts/agentmesh charts/agentmesh-node
helm unittest charts/agentmesh charts/agentmesh-node charts/agentmesh-webapp

.PHONY: verify
verify:
Expand Down Expand Up @@ -281,6 +306,9 @@ docker-build-e2e-runtime:
docker-build-agentmesh-console:
docker build --load --build-arg VERSION="$(VERSION)" -t agentmesh-console:local -f Dockerfile.agentmesh-console .

docker-build: docker-build-control-plane docker-build-router docker-build-node docker-build-one docker-build-mock-oidc docker-build-e2e-runtime docker-build-agentmesh-console
docker-build-agentmesh-webapp:
docker build --load --build-arg VERSION="$(VERSION)" -t agentmesh-webapp:local -f Dockerfile.agentmesh-webapp .

docker-build: docker-build-control-plane docker-build-router docker-build-node docker-build-one docker-build-mock-oidc docker-build-e2e-runtime docker-build-agentmesh-console docker-build-agentmesh-webapp

.PHONY: docker-build-control-plane docker-build-router docker-build-node docker-build-one docker-build-mock-oidc docker-build-e2e-runtime docker-build-agentmesh-console docker-build
.PHONY: docker-build-control-plane docker-build-router docker-build-node docker-build-one docker-build-mock-oidc docker-build-e2e-runtime docker-build-agentmesh-console docker-build-agentmesh-webapp docker-build
6 changes: 6 additions & 0 deletions charts/agentmesh-webapp/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: agentmesh-webapp
description: A Helm chart for deploying Agent Mesh Connect, the web app that puts a browser on any Agent Mesh
type: application
version: 0.2.0
appVersion: "v0.2.0"
36 changes: 36 additions & 0 deletions charts/agentmesh-webapp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# agentmesh-webapp Helm chart

Deploys Agent Mesh Connect, the web app that puts a browser on an Agent Mesh.
The web app knows no control plane: the person using the page enters one, or
opens a join link that names it. One deployment serves any mesh.

## Install

```bash
helm upgrade --install agentmesh-webapp ./charts/agentmesh-webapp --namespace agentmesh-webapp --create-namespace \
--set image.repository=ghcr.io/google/agentmesh-webapp --set image.tag=<version>
```

## Expose it

Browsers refuse the page's cryptography on plain `http` to any host but
`localhost`, so other devices must reach it over `https`.

With `gateway.enabled=true` the chart creates a Gateway and an HTTPRoute:

| Value | Default | Meaning |
| --- | --- | --- |
| `gateway.className` | none, required | The GatewayClass, for example `gke-l7-global-external-managed`. |
| `gateway.path` | `""` | The prefix the page is served under, for example `/node`. Empty serves it at `/`. A prefix needs a GatewayClass that supports `URLRewrite`, and helps only when another route shares the hostname. |
| `gateway.hostnames` | `[]` | The hostnames the route answers. |
| `gateway.listeners` | one `http` listener on port 80 | Put an `https` listener here for other devices. |
| `gateway.addresses`, `gateway.annotations` | empty | Passed to the Gateway as given, for example a static IP or a certificate map. |

Without the Gateway, route the `<release>` Service, port `8082`, from an
`https` proxy or Gateway you already run.

## Sign in

If the mesh's control plane has a sign-in provider, that provider must list
the page's address as a redirect URI and allow its origin. Without that, the
page offers only enrollment tokens.
51 changes: 51 additions & 0 deletions charts/agentmesh-webapp/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "agentmesh-webapp.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "agentmesh-webapp.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "agentmesh-webapp.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "agentmesh-webapp.labels" -}}
helm.sh/chart: {{ include "agentmesh-webapp.chart" . }}
{{ include "agentmesh-webapp.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "agentmesh-webapp.selectorLabels" -}}
app.kubernetes.io/name: {{ include "agentmesh-webapp.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Loading
Loading