|
| 1 | +# Deployment Strategy Guide |
| 2 | + |
| 3 | +Choosing the right deployment target for your ADK agents is critical for success. The ADK supports multiple deployment targets, ranging from fully managed serverless environments to custom containerized infrastructure. |
| 4 | + |
| 5 | +This guide helps you choose the right path based on your specific needs. |
| 6 | + |
| 7 | +## Decision Matrix |
| 8 | + |
| 9 | +Use this matrix to quickly identify the best deployment target for your project. |
| 10 | + |
| 11 | +| Feature | **Agent Engine** (Vertex AI) | **Cloud Run** (Serverless Container) | **GKE / Custom VM** | |
| 12 | +| :--- | :--- | :--- | :--- | |
| 13 | +| **Primary Use Case** | Pure agent logic, rapid prototyping, no-ops | Custom UIs, complex networking, specialized libraries | Enterprise compliance, existing K8s ecosystem | |
| 14 | +| **Management Overhead** | **Low** (Fully Managed) | **Medium** (Container configuration) | **High** (Cluster management) | |
| 15 | +| **State Management** | **Built-in** (Vertex AI Session Service) | **Ephemeral** (Requires external DB for persistence) | **External** (Requires external DB) | |
| 16 | +| **Scaling** | Auto-scaling (Managed) | Auto-scaling (0 to N instances) | Manual or Cluster Autoscaling | |
| 17 | +| **Networking** | Public API Endpoint | VPC connectivity, Custom Domains | Full VPC Control, Service Mesh | |
| 18 | +| **Cost Model** | Pay-per-use (Token/Request) | Compute-based (vCPU/Memory/Time) | Instance-based (Always on) | |
| 19 | + |
| 20 | +## Deployment Paths |
| 21 | + |
| 22 | +### Path A: Vertex AI Agent Engine (Recommended for most) |
| 23 | +**"I just want my agent to run."** |
| 24 | + |
| 25 | +This is the managed service path. You write code, and Google runs it. It supports both the "Accelerated" (Agent Starter Pack) and "Standard" deployment workflows described in the [Agent Engine documentation](./agent-engine.md). |
| 26 | + |
| 27 | +- **Pros**: No Dockerfile needed. No infrastructure config. Built-in conversation history via `VertexAiSessionService`. |
| 28 | +- **Cons**: Restricted runtime environment (cannot install system-level packages like `apt-get`). |
| 29 | +- **Command**: `adk deploy agent_engine` |
| 30 | + |
| 31 | +### Path B: Cloud Run (Native Deployment) |
| 32 | +**"I need a custom UI or specific libraries."** |
| 33 | + |
| 34 | +This acts like "Vercel for Agents". The ADK handles the containerization, but you get a standard Cloud Run service. |
| 35 | +- **Pros**: You can deploy a React frontend alongside your agent (`--with_ui`). You can install system dependencies (e.g., `poppler` for PDF parsing) by modifying the generated Dockerfile. |
| 36 | +- **Cons**: Session state is **ephemeral** by default (stored in memory). If the container restarts or scales down, conversation history is lost unless you configure an external database (Redis/SQL). |
| 37 | +- **Command**: `adk deploy cloud_run` (See [Cloud Run Guide](./cloud-run.md)) |
| 38 | + |
| 39 | +### Path C: Container / GKE |
| 40 | +**"I have strict enterprise compliance requirements."** |
| 41 | + |
| 42 | +You package the agent as a Docker container yourself and deploy it to your existing infrastructure. |
| 43 | +- **Pros**: Complete control. Meets strict IT/Security policies. |
| 44 | +- **Cons**: You own the build pipeline, security patching, and orchestration. |
| 45 | +- **Guide**: See [GKE Guide](./gke.md) |
| 46 | + |
| 47 | +## Common Deployment Gotchas |
| 48 | + |
| 49 | +### Environment Variables |
| 50 | +- **Agent Engine**: The `adk deploy agent_engine` command reads your local `.env` file at **deployment time** to configure the service. |
| 51 | + - *Tip*: If you exclude `.env` from version control (recommended), ensure you create one in your deployment environment (e.g., CI/CD pipeline) before running the deploy command. |
| 52 | +- **Cloud Run**: Variables can be passed during deployment or updated later on the service. |
| 53 | + ```bash |
| 54 | + adk deploy cloud_run --service_name my-agent |
| 55 | + gcloud run services update my-agent --set-env-vars KEY=VALUE |
| 56 | + ``` |
| 57 | + |
| 58 | +### File Uploads |
| 59 | +If your agent processes files (PDFs, Images): |
| 60 | +- **Agent Engine**: Handles file storage automatically within the managed session context. |
| 61 | +- **Cloud Run**: You must implement a mechanism to accept file uploads (e.g., multipart/form-data) and store them (e.g., in Google Cloud Storage) before passing the URI to the agent, as the container's filesystem is ephemeral. |
0 commit comments