|
| 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 (Sessions API) | External (Redis/SQL required) | External (Redis/SQL required) | |
| 16 | +| **Scaling** | Auto-scaling (per request) | 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 "Accelerated" path. You write code, and Google runs it. |
| 26 | +- **Pros**: No Dockerfile needed. No infrastructure config. Built-in conversation history. |
| 27 | +- **Cons**: Less control over the runtime environment. |
| 28 | +- **Command**: `adk deploy agent_engine` |
| 29 | + |
| 30 | +### Path B: Cloud Run (Native Deployment) |
| 31 | +**"I need a custom UI or specific libraries."** |
| 32 | + |
| 33 | +This acts like "Vercel for Agents". The ADK handles the containerization, but you get a standard Cloud Run service. |
| 34 | +- **Pros**: You can deploy a React frontend alongside your agent. You can install system dependencies (like `poppler` for PDF parsing). |
| 35 | +- **Cons**: You must manage session state (if you need persistence beyond memory). |
| 36 | +- **Command**: `adk deploy cloud_run` (See [Cloud Run Guide](./cloud-run.md)) |
| 37 | + |
| 38 | +### Path C: Container / GKE |
| 39 | +**"I have strict enterprise compliance requirements."** |
| 40 | + |
| 41 | +You package the agent as a Docker container yourself and deploy it to your existing infrastructure. |
| 42 | +- **Pros**: Complete control. Meets strict IT/Security policies. |
| 43 | +- **Cons**: You own the build pipeline, security patching, and orchestration. |
| 44 | +- **Guide**: See [Container Deployment](./container.md) |
| 45 | + |
| 46 | +## Common Deployment Gotchas |
| 47 | + |
| 48 | +### Environment Variables |
| 49 | +- **Agent Engine**: Variables in your local `.env` are **not** automatically uploaded for security reasons. You must specify an env file during deploy: |
| 50 | + ```bash |
| 51 | + adk deploy agent_engine --env_file .env.prod |
| 52 | + ``` |
| 53 | +- **Cloud Run**: Variables must be set on the service after deployment or passed via flags: |
| 54 | + ```bash |
| 55 | + adk deploy cloud_run --service_name my-agent |
| 56 | + gcloud run services update my-agent --set-env-vars KEY=VALUE |
| 57 | + ``` |
| 58 | + |
| 59 | +### File Uploads |
| 60 | +If your agent processes files (PDFs, Images): |
| 61 | +- **Agent Engine**: Handles file storage automatically within the session context. |
| 62 | +- **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. |
0 commit comments