Cloud Infrastructure (GCP, PubSub)
Relevant source files
The following files were used as context for generating this wiki page:
Speakeasy's cloud infrastructure utilizes Google Cloud Platform (GCP) as its primary foundation, specifically leveraging Pub/Sub for asynchronous messaging and Google Kubernetes Engine (GKE) for workload orchestration. The system follows a "design-first" approach where the messaging topology is declared via Protobuf descriptors, which serve as the source of truth for generating infrastructure configuration and visualizing system flows. Sources: infra/internal/diagram/diagram.go:11-20, README.md:104-110
The infrastructure supports secure AI scaling by integrating deep observability and fine-grained permissions. It provides a control layer for connecting agents to internal systems via private networking and tunneling deployed on demand. Sources: README.md:20-25, README.md:52-56
Pub/Sub Topology and Orchestration
The Pub/Sub system manages data flow through topics and subscriptions declared in Protobuf. This topology is compiled into descriptors that drive both the deployment (via KCC YAML) and the generation of documentation diagrams. Sources: infra/internal/diagram/diagram.go:12-25
Messaging Components
The messaging architecture distinguishes between standard topics, Dead Letter Queues (DLQ), and storage-backed subscriptions.
- Topics: Act as named channels for messages. Regular topics handle standard traffic, while DLQs capture failed messages for later inspection. Sources: infra/internal/diagram/diagram.go:705-715
- Subscriptions: Define how messages are consumed. The system supports standard push/pull subscriptions and GCS-backed subscriptions that persist messages as Parquet files in Google Cloud Storage. Sources: infra/internal/diagram/diagram.go:725-740
- Call Sites: The Go (
server/) and Python (pystreams/) codebases interact with these topics using specific call shapes identified during static analysis. Sources: infra/internal/diagram/diagram.go:94-115
Data Flow Diagram
This diagram represents the logical flow from publishers through the Pub/Sub topology to consumers or storage.
Workload Identity and GKE Integration
Speakeasy integrates with Google Kubernetes Engine (GKE) using Workload Identity for secure, credential-less authentication. Instead of storing long-lived secrets, pods use projected service account tokens issued for the Speakeasy audience. Sources: client/dashboard/src/pages/agents/credentials/GkeSetupInstructions.tsx:140-150
GKE Authentication Flow
- Cluster Discovery: Each cluster acts as its own OIDC issuer. The system discovers the cluster's issuer URL via
.well-known/openid-configuration. Sources: client/dashboard/src/pages/agents/credentials/GkeSetupInstructions.tsx:24-25 - Token Projection: Kubernetes projects a service account token into the pod at
/var/run/secrets/speakeasy/token. Sources: client/dashboard/src/pages/agents/credentials/GkeSetupInstructions.tsx:17-18 - Audience Validation: Tokens must be issued for the specific Speakeasy audience URL. Speakeasy refuses tokens issued for any other audience. Sources: client/dashboard/src/pages/agents/credentials/GkeSetupInstructions.tsx:165-170
- Exchange: The workload reads the projected token file and exchanges it for a Speakeasy access token, which typically lasts 15 minutes. Sources: client/dashboard/src/pages/agents/credentials/GkeSetupInstructions.tsx:210-215
Workload Authentication Sequence
The following sequence shows how a GKE pod authenticates with the Speakeasy server.
Static Infrastructure Analysis
The project includes an internal tool (infra/internal/diagram) to verify that the declared GCP infrastructure matches the actual implementation in code. It uses ast-grep to scan Go and Python files for Pub/Sub interaction patterns. Sources: infra/internal/diagram/diagram.go:15-30
Scan Patterns
| Role | Language | Pattern | Description |
|---|---|---|---|
| Subscribe | Go | mustReceive($G, $MSG, $SUB, $$$HANDLER) | Standard subscription registration. |
| Subscribe | Go | mustReceiveBatch($G, $MSG, $SUB, $$$HANDLER) | Batch subscription consumption. |
| Subscribe | Python | $R.receive($MSG, $SUB, $$$HANDLER) | Python receiver group registration. |
| Publish | Go | $P.$T{$$$F} | Message construction (publisher detection). |
| Publish | Python | $P.$T($$$A) | Python class instantiation for publishing. |
Sources: infra/internal/diagram/diagram.go:94-145
Development Infrastructure
Local development replicates cloud behavior using Docker and the mise task runner.
- Infra Containers:
mise run startor./zerospins up local versions of infrastructure components like Postgres and ClickHouse. Sources: CONTRIBUTING.md:12-15, CLAUDE.md:18-25 - Networking: The stack supports Tailscale for remote development, allowing services to bind to Tailnet IPs while keeping health listeners on the loopback address. Sources: CONTRIBUTING.md:23-35
- Assistant Runtime: Local assistants can be tested using the
assistants-devMCP server and a local Docker image (gram-assistant-runtime:dev). Sources: CLAUDE.md:142-155
Infrastructure Configuration Summary
The following table summarizes key infrastructure configuration variables found in the project.
| Variable | Description | Source |
|---|---|---|
GRAM_BIND_IP | IP address services bind to (defaults to 127.0.0.1 or Tailnet IP). | CONTRIBUTING.md:27 |
SPEAKEASY_TOKEN_FILE | Environment variable in GKE pods pointing to the projected token. | GkeSetupInstructions.tsx:49 |
expirationSeconds | Lifetime of projected K8s tokens (recommended: 600s). | GkeSetupInstructions.tsx:175 |
COMPOSE_PROJECT_NAME | Remapped per git worktree to avoid container collisions. | CONTRIBUTING.md:162 |
Cloud infrastructure at Speakeasy is designed for high observability and security, ensuring that every tool call and permission change is logged and searchable across the GCP-hosted environment. Sources: README.md:16-20