google-agents-cli-deploy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseADK Deployment Guide
ADK部署指南
Prefer using thecommands throughout this guide — they wrap Terraform, Docker, and deployment into a tested pipeline. If your project isn't scaffolded yet, seeagents-clito add deployment support first./google-agents-cli-scaffold
本指南优先推荐使用命令——它们将Terraform、Docker和部署流程封装为经过验证的流水线。如果你的项目尚未搭建脚手架,请查看agents-cli以先添加部署支持。/google-agents-cli-scaffold
Reference Files
参考文件
For deeper details, consult these reference files in :
references/- — Scaling defaults, Dockerfile, session types, networking
cloud-run.md - — deploy.py CLI, AdkApp pattern, Terraform resource, deployment metadata, CI/CD differences
agent-runtime.md - — GKE Autopilot cluster, Kubernetes manifests, Workload Identity, session types, networking
gke.md - — Custom infrastructure, IAM, state management, importing resources
terraform-patterns.md - — BigQuery Remote Function trigger; for Pub/Sub / Eventarc see
batch-inference.md/google-agents-cli-adk-code - — Full CI/CD pipeline setup,
cicd-pipeline.mdflags, runner comparison, WIF auth, pipeline stagesinfra cicd - — Testing instructions per deployment target, curl examples, load tests
testing-deployed-agents.md
Observability: See theskill for Cloud Trace, prompt-response logging, BigQuery Analytics, and third-party integrations./google-agents-cli-observability
如需深入了解细节,请查阅目录下的以下参考文件:
references/- — 弹性伸缩默认配置、Dockerfile、会话类型、网络配置
cloud-run.md - — deploy.py CLI、AdkApp模式、Terraform资源、部署元数据、CI/CD差异
agent-runtime.md - — GKE Autopilot集群、Kubernetes清单、工作负载身份、会话类型、网络配置
gke.md - — 自定义基础设施、IAM、状态管理、资源导入
terraform-patterns.md - — BigQuery远程函数触发器;Pub/Sub / Eventarc相关内容请查看
batch-inference.md/google-agents-cli-adk-code - — 完整CI/CD流水线搭建、
cicd-pipeline.md参数、运行器对比、WIF认证、流水线阶段infra cicd - — 各部署目标的测试说明、curl示例、负载测试
testing-deployed-agents.md
可观测性: Cloud Trace、提示响应日志、BigQuery分析及第三方集成相关内容,请查看技能。/google-agents-cli-observability
Deployment Target Decision Matrix
部署目标决策矩阵
Choose the right deployment target based on your requirements:
| Criteria | Agent Runtime | Cloud Run | GKE |
|---|---|---|---|
| Languages | Python | Python | Python (+ others via custom containers) |
| Scaling | Managed auto-scaling (configurable min/max, concurrency) | Fully configurable (min/max instances, concurrency, CPU allocation) | Full Kubernetes scaling (HPA, VPA, node auto-provisioning) |
| Networking | VPC-SC and PSC supported | Full VPC support, direct VPC egress, IAP, ingress rules | Full Kubernetes networking |
| Session state | Native | In-memory (dev), Cloud SQL, or Agent Platform Sessions backend | In-memory (dev), Cloud SQL, or Agent Platform Sessions backend |
| Batch/event processing | Not supported | Native trigger endpoints (Pub/Sub, Eventarc); see | Custom (Kubernetes Jobs, Pub/Sub) |
| Cost model | vCPU-iours + memory-iours (not billed when idle) | Per-instance-second + min instance costs | Node pool costs (always-on or auto-provisioned) |
| Setup complexity | Lower (managed, purpose-built for agents) | Medium (Dockerfile, Terraform, networking) | Higher (Kubernetes expertise required) |
| Best for | Managed infrastructure, minimal ops | Custom infra, event-driven workloads | Full Kubernetes control |
Ask the user which deployment target fits their needs. Each is a valid production choice with different trade-offs.
Product name mapping: "Agent Engine" / "Vertex AI Agent Engine" is now Agent Runtime. Use.--deployment-target agent_runtime
Ambient / scheduled / event-driven agents: Agent Runtime does not support Pub/Sub, Eventarc, or Cloud Scheduler triggers. Use Cloud Run (recommended) or GKE for these workloads. SeeSection 12 for the/google-agents-cli-adk-codepattern.trigger_sources
OAuth / user consent agents: Use Agent Runtime with Gemini Enterprise for agents that need OAuth 2.0 user consent (e.g., accessing Google Drive, Calendar, or other user-scoped APIs). Cloud Run does not currently support managed OAuth flows. See thesample inadk-ae-oauthPhase 2./google-agents-cli-workflow
根据你的需求选择合适的部署目标:
| 评估标准 | Agent Runtime | Cloud Run | GKE |
|---|---|---|---|
| 支持语言 | Python | Python | Python(自定义容器可支持其他语言) |
| 弹性伸缩 | 托管式自动伸缩(可配置最小/最大实例数、并发数) | 完全可配置(最小/最大实例数、并发数、CPU分配) | 完整Kubernetes伸缩能力(HPA、VPA、节点自动配置) |
| 网络配置 | 支持VPC-SC和PSC | 完整VPC支持、直接VPC出站、IAP、入站规则 | 完整Kubernetes网络能力 |
| 会话状态 | 原生 | 内存存储(开发环境)、Cloud SQL或Agent Platform Sessions后端 | 内存存储(开发环境)、Cloud SQL或Agent Platform Sessions后端 |
| 批量/事件处理 | 不支持 | 原生触发器端点(Pub/Sub、Eventarc);详情请查看 | 自定义实现(Kubernetes Jobs、Pub/Sub) |
| 计费模式 | vCPU时长 + 内存时长(空闲时不计费) | 按实例秒数计费 + 最小实例成本 | 节点池成本(持续运行或自动配置) |
| 搭建复杂度 | 较低(托管式、专为Agent打造) | 中等(Dockerfile、Terraform、网络配置) | 较高(需具备Kubernetes专业知识) |
| 适用场景 | 托管式基础设施、最小化运维 | 自定义基础设施、事件驱动型工作负载 | 完全Kubernetes控制能力 |
请询问用户哪种部署目标符合他们的需求。每个选项都是有效的生产环境选择,各有不同的权衡。
产品名称映射: "Agent Engine" / "Vertex AI Agent Engine"现更名为Agent Runtime。请使用参数。--deployment-target agent_runtime
后台/定时/事件驱动型Agent: Agent Runtime不支持Pub/Sub、Eventarc或Cloud Scheduler触发器。此类工作负载请使用Cloud Run(推荐)或GKE。模式详情请查看trigger_sources第12节。/google-agents-cli-adk-code
OAuth / 用户授权Agent: 需要OAuth 2.0用户授权(例如访问Google Drive、Calendar或其他用户范围API)的Agent,请使用Agent Runtime搭配Gemini Enterprise。Cloud Run目前不支持托管式OAuth流程。示例请查看第2阶段的/google-agents-cli-workflow样本。adk-ae-oauth
Deploying to Dev
部署到开发环境
Deploy Workflow
部署工作流
Task tracking: Deployment involves multiple sequential steps (infra setup, CI/CD configuration, deploy, verification). Use a task list to track progress through these steps — skipping one often causes failures in later steps that are hard to trace back.
- If prototype (no deployment target), first enhance:
agents-cli scaffold enhance . --deployment-target <target> - Notify the human: "Eval scores meet thresholds and tests pass. Ready to deploy to dev?"
- Wait for explicit approval
- Once approved:
agents-cli deploy
Agent Runtime timeout recovery: Agent Runtime deploys can take 5-10 minutes and may exceed command timeouts. If the deploy command is cancelled or times out, the deployment continues server-side. Runto check progress — poll every 60 seconds until it reports completion or failure.agents-cli deploy --status
IMPORTANT: Never run without explicit human approval.
agents-cli deployDo NOT runbefore deploying. It is not a prerequisite —agents-cli infra single-projectworks on its own. Run it separately if the user needs observability features (prompt-response logging, BigQuery analytics) — seeagents-cli deploy./google-agents-cli-observability
任务跟踪: 部署涉及多个连续步骤(基础设施搭建、CI/CD配置、部署、验证)。请使用任务列表跟踪这些步骤的进度——跳过某一步通常会导致后续步骤出现难以追溯的故障。
- 如果是原型项目(无部署目标),先增强项目配置:
agents-cli scaffold enhance . --deployment-target <target> - 告知用户:"评估分数已达阈值且测试通过。是否准备部署到开发环境?"
- 等待明确的批准
- 获得批准后执行:
agents-cli deploy
Agent Runtime超时恢复: Agent Runtime部署可能需要5-10分钟,可能会超出命令超时时间。如果部署命令被取消或超时,部署仍会在服务器端继续进行。运行检查进度——每60秒轮询一次,直到显示完成或失败。agents-cli deploy --status
重要提示:未经用户明确批准,切勿运行命令。
agents-cli deploy部署前请勿运行。这不是部署的前置条件——agents-cli infra single-project可独立运行。如果用户需要可观测性功能(提示响应日志、BigQuery分析),可单独运行该命令——详情请查看agents-cli deploy。/google-agents-cli-observability
Single-Project Infrastructure Setup (Optional — Advanced)
单项目基础设施搭建(可选——高级功能)
agents-cli infra single-projectterraform applydeployment/terraform/single-project/bash
undefinedagents-cli infra single-projectdeployment/terraform/single-project/terraform applybash
undefinedOptional — provision infrastructure in a single GCP project
可选——在单个GCP项目中搭建基础设施
agents-cli infra single-project
> **Note:** `agents-cli deploy` doesn't automatically use the Terraform-created `app_sa`. Pass the service account via `agents-cli deploy --service-account SA_EMAIL` or `uv run -m app.app_utils.deploy --service-account SA_EMAIL` for Agent Runtime targets.agents-cli infra single-project
> **注意:** `agents-cli deploy`不会自动使用Terraform创建的`app_sa`。对于Agent Runtime目标,请通过`agents-cli deploy --service-account SA_EMAIL`或`uv run -m app.app_utils.deploy --service-account SA_EMAIL`参数传入服务账号。Deploy Flag Reference
部署参数参考
| Flag | Description | Targets |
|---|---|---|
| GCP project ID | All |
| GCP region | All |
| Service account email for the deployed agent | All |
| Comma-separated | Agent Runtime |
| Comma-separated | Agent Runtime, Cloud Run |
| Enable agent identity (Preview) | Agent Runtime |
| Memory limit (default: | Cloud Run |
| Container port | Cloud Run |
| Enable Identity-Aware Proxy | Cloud Run |
| Container image URI (skips source build) | Cloud Run, GKE |
| Start deployment and return immediately | Agent Runtime, Cloud Run |
| Check the status of a pending | Agent Runtime, Cloud Run |
| List existing deployments and exit | All |
| Print what would be executed without running it | All |
| Skip project confirmation prompt | All |
Run for the full flag reference. Cloud Run also accepts extra flags after (e.g., ).
agents-cli deploy --helpgcloud---- --timeout=600Project Confirmation: If the project is resolved automatically (not passed via), the command will prompt for confirmation in interactive mode. Since agents typically run in non-interactive mode, you MUST pass--projectto proceed if you are relying on automatic project resolution.--no-confirm-project
| 参数 | 描述 | 适用目标 |
|---|---|---|
| GCP项目ID | 所有 |
| GCP区域 | 所有 |
| 部署后Agent使用的服务账号邮箱 | 所有 |
| 逗号分隔的 | Agent Runtime |
| 逗号分隔的 | Agent Runtime、Cloud Run |
| 启用Agent身份(预览版) | Agent Runtime |
| 内存限制(默认: | Cloud Run |
| 容器端口 | Cloud Run |
| 启用Identity-Aware Proxy | Cloud Run |
| 容器镜像URI(跳过源码构建) | Cloud Run、GKE |
| 启动部署后立即返回,不等待完成 | Agent Runtime、Cloud Run |
| 检查 | Agent Runtime、Cloud Run |
| 列出现有部署并退出 | 所有 |
| 打印将要执行的操作但不实际运行 | 所有 |
| 跳过项目确认提示 | 所有 |
运行查看完整参数参考。Cloud Run还支持在后添加额外的参数(例如:)。
agents-cli deploy --help--gcloud-- --timeout=600项目确认: 如果项目是自动解析的(未通过参数传入),命令在交互模式下会提示确认。由于Agent通常运行在非交互模式下,若依赖自动项目解析,必须传入--project参数才能继续执行。--no-confirm-project
Production Deployment — CI/CD Pipeline
生产环境部署——CI/CD流水线
For the full CI/CD pipeline setup guide — prerequisites, flags, runner comparison, WIF authentication, pipeline stages, and production approval — see .
infra cicdreferences/cicd-pipeline.md完整CI/CD流水线搭建指南(前置条件、参数、运行器对比、WIF认证、流水线阶段、生产环境批准流程)请查看。
infra cicdreferences/cicd-pipeline.mdCloud Run Specifics
Cloud Run专属配置
For detailed infrastructure configuration (scaling defaults, Dockerfile, FastAPI endpoints, session types, networking), see . For ADK docs on Cloud Run deployment, fetch .
references/cloud-run.mdhttps://adk.dev/deploy/cloud-run/index.mdFor event-driven / ambient agent deployment on Cloud Run, see the sample and for the pattern.
ambient-expense-agent/google-agents-cli-adk-codetrigger_sources详细基础设施配置(弹性伸缩默认值、Dockerfile、FastAPI端点、会话类型、网络配置)请查看。ADK官方Cloud Run部署文档请访问。
references/cloud-run.mdhttps://adk.dev/deploy/cloud-run/index.mdCloud Run上的事件驱动/后台Agent部署示例,请查看样本及中的模式。
ambient-expense-agent/google-agents-cli-adk-codetrigger_sourcesAgent Runtime Specifics
Agent Runtime专属配置
Agent Runtime is a managed Vertex AI service for deploying Python ADK agents. Uses source-based deployment (no Dockerfile) via and the class.
deploy.pyAdkAppNoCLI exists for Agent Runtime. Deploy viagcloudoragents-cli deploy. Query via the Pythondeploy.pySDK.vertexai.Client
Deployments can take 5-10 minutes. Use to start a deployment and return immediately, then check on it later with :
--no-wait--statusbash
undefinedAgent Runtime是用于部署Python ADK Agent的托管式Vertex AI服务。通过和类实现基于源码的部署(无需Dockerfile)。
deploy.pyAdkAppAgent Runtime没有CLI命令。请通过gcloud或agents-cli deploy进行部署。通过Pythondeploy.pySDK进行查询。vertexai.Client
部署可能需要5-10分钟。使用参数启动部署后立即返回,之后通过检查进度:
--no-wait--statusbash
undefinedStart deployment without blocking
启动部署,不阻塞当前进程
agents-cli deploy --no-wait
agents-cli deploy --no-wait
Check on progress later
稍后检查进度
agents-cli deploy --status
When `--status` detects the operation has completed, it writes `deployment_metadata.json` and prints the same success output as a normal deploy.
For detailed infrastructure configuration (deploy.py flags, AdkApp pattern, Terraform resource, deployment metadata, session/artifact services, CI/CD differences), see `references/agent-runtime.md`. For ADK docs on Agent Runtime deployment, fetch `https://adk.dev/deploy/agent-engine/index.md`.
---agents-cli deploy --status
当`--status`检测到操作完成时,会写入`deployment_metadata.json`并打印与正常部署相同的成功输出。
详细基础设施配置(deploy.py参数、AdkApp模式、Terraform资源、部署元数据、会话/工件服务、CI/CD差异)请查看`references/agent-runtime.md`。ADK官方Agent Runtime部署文档请访问`https://adk.dev/deploy/agent-engine/index.md`。
---GKE Specifics
GKE专属配置
For detailed infrastructure configuration (Kubernetes manifests, Terraform resources, Workload Identity, session types, networking), see . For ADK docs on GKE deployment, fetch .
references/gke.mdhttps://adk.dev/deploy/gke/index.md详细基础设施配置(Kubernetes清单、Terraform资源、工作负载身份、会话类型、网络配置)请查看。ADK官方GKE部署文档请访问。
references/gke.mdhttps://adk.dev/deploy/gke/index.mdService Account Architecture
服务账号架构
Scaffolded projects use two service accounts:
- (per environment) — Runtime identity for the deployed agent. Roles defined in
app_sa.deployment/terraform/iam.tf - (CI/CD project) — CI/CD pipeline identity (GitHub Actions / Cloud Build). Lives in the CI/CD project (defaults to prod project), needs permissions in both staging and prod projects.
cicd_runner_sa
Check for exact role bindings. Cross-project permissions (Cloud Run service agents, artifact registry access) are also configured there.
deployment/terraform/iam.tfCommon 403 errors:
- "Permission denied on Cloud Run" → missing deployment role in the target project
cicd_runner_sa - "Cannot act as service account" → Missing binding on
iam.serviceAccountUserapp_sa - "Secret access denied" → missing
app_sasecretmanager.secretAccessor - "Artifact Registry read denied" → Cloud Run service agent missing read access in CI/CD project
脚手架生成的项目使用两个服务账号:
- (按环境区分)—— 部署后Agent的运行时身份。角色定义在
app_sa中。deployment/terraform/iam.tf - (CI/CD项目)—— CI/CD流水线身份(GitHub Actions / Cloud Build)。位于CI/CD项目中(默认是生产环境项目),需要同时拥有 staging 和生产环境项目的权限。
cicd_runner_sa
请查看获取确切的角色绑定。跨项目权限(Cloud Run服务代理、Artifact Registry访问)也在此文件中配置。
deployment/terraform/iam.tf常见403错误:
- "Cloud Run权限被拒绝" → 缺少目标项目的部署角色
cicd_runner_sa - "无法扮演服务账号" → 缺少
app_sa绑定iam.serviceAccountUser - "密钥访问被拒绝" → 缺少
app_sa角色secretmanager.secretAccessor - "Artifact Registry读取被拒绝" → Cloud Run服务代理缺少CI/CD项目的读取权限
Required Permissions for CI/CD Setup
CI/CD搭建所需权限
- granted to the Cloud Build service account (
roles/secretmanager.admin) in the CI/CD project. This allows Cloud Build to access the GitHub token stored in Secret Manager.service-<PROJECT_NUMBER>@gcp-sa-cloudbuild.iam.gserviceaccount.com
- — 授予CI/CD项目中的Cloud Build服务账号(
roles/secretmanager.admin)。此权限允许Cloud Build访问存储在Secret Manager中的GitHub令牌。service-<PROJECT_NUMBER>@gcp-sa-cloudbuild.iam.gserviceaccount.com
Required APIs
必需启用的API
The following Google Cloud APIs must be enabled in your project for the skills and deployment to work:
- — Required for building container images and running CI/CD pipelines.
cloudbuild.googleapis.com - — Required for managing secrets and API keys.
secretmanager.googleapis.com - — Required for deploying to Cloud Run.
run.googleapis.com
Ensure these are enabled before running deployment or CI/CD setup commands:
bash
gcloud services enable cloudbuild.googleapis.com secretmanager.googleapis.com run.googleapis.com --project=YOUR_PROJECT_ID为确保技能和部署正常工作,你的项目必须启用以下Google Cloud API:
- — 构建容器镜像和运行CI/CD流水线必需。
cloudbuild.googleapis.com - — 管理密钥和API密钥必需。
secretmanager.googleapis.com - — 部署到Cloud Run必需。
run.googleapis.com
在运行部署或CI/CD搭建命令前,请确保这些API已启用:
bash
gcloud services enable cloudbuild.googleapis.com secretmanager.googleapis.com run.googleapis.com --project=YOUR_PROJECT_IDSecret Manager (for API Credentials)
Secret Manager(用于API凭证)
Instead of passing sensitive keys as environment variables, use GCP Secret Manager.
bash
undefined请勿将敏感密钥作为环境变量传递,请使用GCP Secret Manager。
bash
undefinedCreate a secret
创建密钥
echo -n "YOUR_API_KEY" | gcloud secrets create MY_SECRET_NAME --data-file=-
echo -n "YOUR_API_KEY" | gcloud secrets create MY_SECRET_NAME --data-file=-
Update an existing secret
更新现有密钥
echo -n "NEW_API_KEY" | gcloud secrets versions add MY_SECRET_NAME --data-file=-
**Grant access:** For Cloud Run, grant `secretmanager.secretAccessor` to `app_sa`. For Agent Runtime, grant it to the platform-managed SA (`service-PROJECT_NUMBER@gcp-sa-aiplatform-re.iam.gserviceaccount.com`). For GKE, grant `secretmanager.secretAccessor` to `app_sa`. Access secrets via Kubernetes Secrets or directly via the Secret Manager API with Workload Identity.
**Pass secrets at deploy time (Agent Runtime):**
```bash
agents-cli deploy --secrets "API_KEY=my-api-key,DB_PASS=db-password:2"Format: or (defaults to latest). Access in code via .
ENV_VAR=SECRET_IDENV_VAR=SECRET_ID:VERSIONos.environ.get("API_KEY")echo -n "NEW_API_KEY" | gcloud secrets versions add MY_SECRET_NAME --data-file=-
**授权访问:** 对于Cloud Run,授予`app_sa` `secretmanager.secretAccessor`角色。对于Agent Runtime,授予平台托管的服务账号(`service-PROJECT_NUMBER@gcp-sa-aiplatform-re.iam.gserviceaccount.com`)该角色。对于GKE,授予`app_sa` `secretmanager.secretAccessor`角色。可通过Kubernetes Secrets或使用工作负载身份直接调用Secret Manager API访问密钥。
**部署时传入密钥(Agent Runtime):**
```bash
agents-cli deploy --secrets "API_KEY=my-api-key,DB_PASS=db-password:2"格式:或(默认使用最新版本)。在代码中通过访问。
ENV_VAR=SECRET_IDENV_VAR=SECRET_ID:VERSIONos.environ.get("API_KEY")Observability
可观测性
See the agents-cli-observability skill for observability configuration (Cloud Trace, prompt-response logging, BigQuery Analytics, third-party integrations).
可观测性配置(Cloud Trace、提示响应日志、BigQuery分析、第三方集成)请查看agents-cli-observability技能。
Testing Your Deployed Agent
测试已部署的Agent
The quickest way to test a deployed agent is — it handles auth, sessions, and streaming automatically (supports Agent Runtime and Cloud Run).
agents-cli run --url <service-url> --mode <a2a|adk> "your prompt"For advanced testing (custom headers, session reuse, scripting, load tests), see .
references/testing-deployed-agents.md测试已部署Agent的最快方式是——它会自动处理认证、会话和流式传输(支持Agent Runtime和Cloud Run)。
agents-cli run --url <service-url> --mode <a2a|adk> "your prompt"高级测试(自定义请求头、会话复用、脚本、负载测试)请查看。
references/testing-deployed-agents.mdDeploying with a UI (IAP)
带UI的部署(IAP)
IAP (Identity-Aware Proxy) secures a Cloud Run service so only authorized Google accounts can access it. Support for IAP deployment via is planned for a future release.
agents-cli deployFor Agent Runtime with a custom frontend, use a decoupled deployment — deploy the frontend separately to Cloud Run or Cloud Storage, connecting to the Agent Runtime backend API.
For more information on IAP with Cloud Run, see the Cloud Console IAP settings.
IAP(Identity-Aware Proxy)可保护Cloud Run服务,仅允许授权的Google账号访问。对IAP部署的支持计划在未来版本中推出。
agents-cli deploy对于带有自定义前端的Agent Runtime,请使用解耦部署——将前端单独部署到Cloud Run或Cloud Storage,连接到Agent Runtime后端API。
Cloud Run搭配IAP的更多信息,请查看Cloud Console IAP设置。
Rollback & Recovery
回滚与恢复
The primary rollback mechanism is git-based: fix the issue, commit, and push to . The CI/CD pipeline will automatically build and deploy the new version through staging → production.
mainFor immediate Cloud Run rollback without a new commit, use revision traffic shifting:
bash
gcloud run revisions list --service=SERVICE_NAME --region=REGION
gcloud run services update-traffic SERVICE_NAME \
--to-revisions=REVISION_NAME=100 --region=REGIONAgent Runtime doesn't support revision-based rollback — fix and redeploy via .
agents-cli deployFor GKE rollback, use :
kubectl rollout undobash
kubectl rollout undo deployment/DEPLOYMENT_NAME -n NAMESPACE
kubectl rollout status deployment/DEPLOYMENT_NAME -n NAMESPACE主要的回滚机制是基于Git:修复问题、提交并推送到分支。CI/CD流水线会自动构建并将新版本通过staging → 生产环境的流程部署。
main无需新提交即可立即回滚Cloud Run版本,可使用修订版流量切换:
bash
gcloud run revisions list --service=SERVICE_NAME --region=REGION
gcloud run services update-traffic SERVICE_NAME \
--to-revisions=REVISION_NAME=100 --region=REGIONAgent Runtime不支持基于修订版的回滚——修复问题后通过重新部署。
agents-cli deployGKE回滚请使用:
kubectl rollout undobash
kubectl rollout undo deployment/DEPLOYMENT_NAME -n NAMESPACE
kubectl rollout status deployment/DEPLOYMENT_NAME -n NAMESPACECustom Infrastructure (Terraform)
自定义基础设施(Terraform)
CRITICAL: When your agent requires custom infrastructure (Cloud SQL, Pub/Sub, Eventarc, BigQuery, etc.), you MUST define it in Terraform — never create resources manually via commands. Exception: quick experimentation is fine with or console, but production infrastructure must be in Terraform.
gcloudgcloudFor custom infrastructure patterns, consult for:
references/terraform-patterns.md- Where to put custom Terraform files (single-project vs CI/CD)
- Resource examples (Pub/Sub, BigQuery, Eventarc triggers)
- IAM bindings for custom resources
- Terraform state management (remote vs local, importing resources)
- Common infrastructure patterns
关键提示:当你的Agent需要自定义基础设施(Cloud SQL、Pub/Sub、Eventarc、BigQuery等)时,必须在Terraform中定义——切勿通过命令手动创建资源。例外情况:使用或控制台进行快速实验是可行的,但生产环境基础设施必须通过Terraform管理。
gcloudgcloud自定义基础设施模式请查看,内容包括:
references/terraform-patterns.md- 自定义Terraform文件的存放位置(单项目 vs CI/CD)
- 资源示例(Pub/Sub、BigQuery、Eventarc触发器)
- 自定义资源的IAM绑定
- Terraform状态管理(远程 vs 本地、资源导入)
- 常见基础设施模式
Troubleshooting
故障排查
| Issue | Solution |
|---|---|
| Terraform state locked | |
| GitHub Actions auth failed | Re-run |
| Cloud Build authorization pending | Use |
| Resource already exists | |
| Agent Runtime deploy timeout / hangs | Deployments take 5-10 min; check if engine was created (see Agent Runtime Specifics) |
| Secret not available | Verify |
| 403 on deploy | Check |
| 403 when testing Cloud Run | Default is |
| Cold starts too slow | Set |
| Cloud Run 503 errors | Check resource limits (memory/CPU), increase |
| 403 right after granting IAM role | IAM propagation is not instant — wait a couple of minutes before retrying. Don't keep re-granting the same role |
| Resource seems missing but Terraform created it | Run |
| Deployment failed or agent not responding | Check Cloud Logging: |
| Agent returns errors after deploy | Open Cloud Logging in Console → filter by service name (Cloud Run) or reasoning engine resource (Agent Runtime) → look for Python tracebacks or permission errors in recent log entries |
| 问题 | 解决方案 |
|---|---|
| Terraform状态锁定 | 在deployment/terraform/目录下执行 |
| GitHub Actions认证失败 | 在CI/CD Terraform目录下重新运行 |
| Cloud Build授权等待中 | 改用 |
| 资源已存在 | 使用 |
| Agent Runtime部署超时/挂起 | 部署需要5-10分钟;检查引擎是否已创建(请查看Agent Runtime专属配置部分) |
| 密钥不可用 | 确认 |
| 部署时出现403错误 | 检查 |
| 测试Cloud Run时出现403错误 | 默认配置为 |
| 冷启动过慢 | 在Cloud Run Terraform配置中设置 |
| Cloud Run出现503错误 | 检查资源限制(内存/CPU)、增加 |
| 授予IAM角色后立即出现403错误 | IAM权限生效并非即时——等待几分钟后重试。请勿重复授予相同角色 |
| Terraform已创建资源但似乎缺失 | 运行 |
| 部署失败或Agent无响应 | 查看Cloud Logging:Cloud Run执行 |
| 部署后Agent返回错误 | 在控制台打开Cloud Logging → 按服务名称(Cloud Run)或推理引擎资源(Agent Runtime)过滤 → 查找最近日志中的Python回溯信息或权限错误 |
Platform Registration
平台注册
For registering deployed agents with Gemini Enterprise, see .
/google-agents-cli-publish将已部署的Agent注册到Gemini Enterprise,请查看。
/google-agents-cli-publishRelated Skills
相关技能
- — Development workflow, coding guidelines, and operational rules
/google-agents-cli-workflow - — ADK Python API quick reference for writing agent code
/google-agents-cli-adk-code - — Evaluation methodology, evalset schema, and the eval-fix loop
/google-agents-cli-eval - — Project creation and enhancement with
/google-agents-cli-scaffold/agents-cli scaffold createscaffold enhance - — Cloud Trace, logging, BigQuery Analytics, and third-party integrations
/google-agents-cli-observability - — Gemini Enterprise registration
/google-agents-cli-publish
- — 开发工作流、编码规范及操作规则
/google-agents-cli-workflow - — ADK Python API快速参考,用于编写Agent代码
/google-agents-cli-adk-code - — 评估方法论、评估集 schema 及评估-修复循环
/google-agents-cli-eval - — 通过
/google-agents-cli-scaffold/agents-cli scaffold create创建和增强项目scaffold enhance - — Cloud Trace、日志、BigQuery分析及第三方集成
/google-agents-cli-observability - — Gemini Enterprise注册
/google-agents-cli-publish