google-agents-cli-deploy
Deploys agents with agents-cli to Agent Runtime, Cloud Run or GKE. Use when the user wants to deploy or go to production, add a deployment target or CI/CD, set up Terraform, secrets or IAM, test or roll back a deployed agent, put it behind Agent Gateway, use CMEK, or run batch inference from BigQuery.
작성자를 위한 경고
- 1 "metadata" entries are ignored: expected short text keys and values
Deploy an agent to Google Cloud
Run agents-cli info first: it prints the language and deployment target. No project yet: settle the target in section 1 and record it under ## Deployment in .agents-cli-spec.md. With an approved spec, call the Skill tool with google-agents-cli-scaffold; without one, google-agents-cli-workflow, and finish its design stage.
Before choosing the target, read the framework's skill for this stage: the skill the project's guidance file (CLAUDE.md, GEMINI.md or AGENTS.md) names. On ADK, call the Skill tool with google-agents-cli-adk-code and read its references/adk-deploy.md. No project yet: see workflow's references/extension.md. No Skill tool: read its SKILL.md directly (../<skill-name>/ for a bundled skill, .agents/skills/<skill-name>/ for an extension's).
Use agents-cli commands over raw gcloud, Terraform or Docker: they wrap the tested pipeline. agents-cli <cmd> --help is authoritative for every flag.
References
| File | Read when |
|---|---|
references/agent-runtime.md | Agent Runtime sizing, queries, debugging or rollback |
references/cloud-run.md | Cloud Run sizing, sessions, ingress, IAP, auth or rollback |
references/gke.md | GKE cluster, manifests, Workload Identity, port-forward or rollback |
references/terraform.md | Custom infrastructure, service accounts and 403s, Terraform state, terraform import |
references/cicd.md | Running infra cicd: runners, pipeline stages, production approval |
references/cmek.md | Customer-managed encryption keys |
references/batch-inference.md | Calling the agent from BigQuery over table rows |
references/gateway.md | Binding the agent to an Agent Gateway |
1. Choose the target
Ask which target fits; recommend Agent Runtime for the least operations work.
For production, ask in that round only what changes the setup and isn't known yet, each with a recommended default: who calls the agent and with what access, the region, peak concurrent users (sizing, load test), and personal data in conversations (retention).
Follow company rules the user or repo states over scaffold defaults, without asking for them: residency (references/terraform.md), Terraform modules, base images, keys, model gateway.
| Agent Runtime | Cloud Run | GKE | |
|---|---|---|---|
| Operations | Managed, built for agents | Medium: Dockerfile, Terraform, networking | High: Kubernetes skills |
| Networking | VPC-SC, PSC interface | Full VPC, direct egress, IAP, ingress rules | Full Kubernetes networking |
| Sessions | Managed | In-memory, Cloud SQL or managed | In-memory, Cloud SQL or managed |
| Events | Container routes through the /api passthrough | Pub/Sub push and Eventarc to public routes | Kubernetes Jobs, Pub/Sub |
| Cost | vCPU and memory hours, nothing when idle | Instance-seconds plus min instances | Node pools |
- Agent Runtime builds the project's
Dockerfile. Some frameworks lose Agent Runtime features; the framework's skill says which. ADK Java, Kotlin and TypeScript deploy to Cloud Run only. - Agents that need OAuth user consent (Drive, Calendar) go on Agent Runtime, registered with Gemini Enterprise; Cloud Run has no managed OAuth flow.
- "Agent Engine" means Agent Runtime:
agent_runtime.
The manifest's deployment_target records the choice; deploy -d <target> overrides it once. To add a target to an existing project, run agents-cli scaffold enhance --deployment-target <target> first. Python: check uv run python -c "import app.fast_api_app" (your agent directory for app); on a ModuleNotFoundError, uv add the missing dependencies from a /tmp scaffold of the same target. <!-- remove when scaffold enhance merges the deployment target's dependencies -->
- Ask which session storage when the framework's template offers a choice for that target; the framework's skill lists the options (ADK:
--session-typeoncloud_runandgke, inadk-deploy.md).
2. Get approval before every deploy
Evals pass and the user approves before each deploy, redeploys included:
- Rerun
agents-cli eval runafter the last code change, plus the project's unit and integration tests. If no eval exists yet, call the Skill tool withgoogle-agents-cli-eval. - Paste every case's score and the test results. Include the final
RESULT:line and read the scores against the bar yourself: the exit code gates only on the config'sthresholdsand errored cases. - Ask "Ready to deploy to dev?" and wait.
- On an explicit yes, and after section 3's pre-deploy steps, run
agents-cli deploy --project <id>.
NEVER run agents-cli deploy without an explicit yes from the user. Done when the user said yes after seeing the scores, and only then did deploy run.
3. Provision infrastructure in the right order
agents-cli deploy works on its own, without Terraform. For production, ask the user: one project (agents-cli infra single-project) or staging and prod behind CI/CD (agents-cli infra cicd, section 4).
Before the first deploy, call the Skill tool with google-agents-cli-observability for the tier choice, unless .agents-cli-spec.md already has ## Observability.
Before the first deploy to a project, run agents-cli deploy --dry-run: it prints the plan after read-only Google Cloud checks (Agent Runtime, Cloud Run, GKE) and the offline pre-flight checks, and exits non-zero if one fails. --skip-preflight skips those checks on a real deploy.
Every --apply runs terraform apply -auto-approve, so before each one, or a terraform apply, show the user the plan summary (adds, changes, destroys) and wait for an explicit yes.
When Terraform will own the agent's identity or observability (prompt-response logging, BigQuery telemetry), provision before the first deploy:
agents-cli infra single-projectshows the plan; after that yes,agents-cli infra single-project --applyapplies it. On Agent Runtime this also creates the agent resource that later deploys update.- Deploy as the identity below. Read the manifest's
create_params.<target>.identity_default(agent_runtimeorcloud_run):
| Project | Agent runs as | Deploy with |
|---|---|---|
Agent Runtime or Cloud Run, agent_identity | Its own principal://..., granted agent_identity_roles from variables.tf | agents-cli deploy; it ignores --service-account |
service_account or no key | app_sa | agents-cli deploy --service-account <email>, with app_service_account_email from agents-cli infra show <!-- remove when deploy defaults --service-account to Terraform's app_sa (CLI wave 1) --> |
New projects default to Agent Identity on both targets; an older Cloud Run project (no identity_default) opts in with --agent-identity. On Cloud Run it can't be turned off later: for a service that has it, deploy stops and asks you to delete the service and redeploy. Even with Agent Identity, Cloud Run checks the service account the service records (app_sa from Terraform, else the default compute SA, else the last --service-account) for secretAccessor when it deploys.
Done when the agent runs as that identity; on Agent Runtime, deploy prints it: Agent Identity: principal://... or Service Account: <email>.
If deploy already ran before Terraform, leave Terraform unapplied: it owns the whole Agent Runtime resource, so a later apply leaves a second agent beside the first. Either delete the deployment with the user's ok and redo the steps above, or keep it and call the Skill tool with google-agents-cli-observability to set up telemetry by hand. <!-- remove when the CLI deploy/Terraform order check (wave 1) lands -->
GKE is the exception: deploy runs its own targeted Terraform.
Custom infrastructure (Pub/Sub, BigQuery, Eventarc) goes in Terraform under deployment/terraform/. Done when every resource the agent uses shows in terraform state list. A 409 or "already exists" means terraform import, not a new resource.
Keep Terraform state remote, in GCS: infra cicd sets up the bucket and backend.tf; pass --local-state only for a one-person throwaway. With infra single-project alone, add a gcs backend before the first --apply (references/terraform.md); if CI/CD will follow, use the bucket and prefix infra cicd will write there. Done when deployment/terraform/*/backend.tf declares backend "gcs".
4. Set up CI/CD
agents-cli infra cicd provisions staging, prod and the pipeline. First:
- Ask which runner: GitHub Actions (uses
gh auth) or Cloud Build (needs a PAT and app installation ID). - Collect the staging and prod project IDs and the GitHub repository. The project must sit outside gitignored directories.
- Confirm the repository name and visibility before
--createmakes one, and before any push. - A prototype runs
agents-cli scaffold enhance --cicd-runner <runner>first, plus--deployment-target <target>ifagents-cli infoshowsnone: onnonethe runner alone adds no CI files.
Ask before running infra cicd: even without --apply it creates the state bucket and the Cloud Build github-pat secret, and rewrites both backend.tf files. Pass the PAT as $GH_TOKEN, never a literal. Run --apply only after the user approves the plan. It deploys nothing: push to main to start the pipeline. Details, path filters and production approval: references/cicd.md.
5. Store secrets in Secret Manager
API keys and passwords live in Secret Manager and reach the agent by name, not in env vars, code, logs or committed files. Never take a secret value in chat; the user creates the secret in their shell:
echo -n "$API_KEY" | gcloud secrets create MY_API_KEY --project="$PROJECT_ID" --data-file=-
gcloud secrets add-iam-policy-binding MY_API_KEY --project="$PROJECT_ID" \
--member="principal://..." --role="roles/secretmanager.secretAccessor"
Grant on that one secret to the runtime identity, principal://... or serviceAccount:<email>; in Terraform, google_secret_manager_secret_iam_member (references/terraform.md). Not through agent_identity_roles or app_sa_roles: those grant project-wide, opening every secret. Deploy to Agent Runtime or Cloud Run with --secrets "API_KEY=MY_API_KEY" (Agent Runtime replaces the agent's secrets with the ones you pass; Cloud Run adds to them); GKE pods read secrets through Kubernetes Secrets or the Secret Manager API with Workload Identity. Grant once the identity exists (references/terraform.md, Granting roles).
For CI/CD: references/cicd.md, Secrets.
Done when the deployed config names the secret, holds no key value, and the runtime identity holds secretAccessor.
Change config later with --env-vars KEY=VALUE, --remove-secrets KEY, --remove-env-vars KEY, --clear-secrets and --clear-env-vars (Agent Runtime and Cloud Run; --env-vars also on GKE). Every deploy applies the project .env; --remove-* ignores keys that don't exist and refuses a key you also set, in --env-vars or .env, and keeps agents-cli's own defaults (AGENT_VERSION, APP_URL). --clear-env-vars runs first, then the deploy sets .env, --env-vars and the defaults, and secrets stay. --clear-* also removes values set outside agents-cli, such as Terraform's LOGS_BUCKET_NAME, OTEL_* or DB_PASS; --clear-secrets plus --secrets replaces the set, and on Cloud Run it also removes volume-mounted secrets. A --remove-* can't be combined with the matching --clear-*. On GKE a deploy without --image resets env vars to Terraform's, so keep lasting ones in .env or Terraform.
A 403 right after a grant is IAM propagation: retry in a few minutes. Others: references/terraform.md.
6. Test the deployed agent
agents-cli run --url <base-url> --mode a2a "What can you do?"
run --url handles auth, sessions and streaming; pass the base URL, not the card path. If an extension overrides run, prefix AGENTS_CLI_DISABLE_OVERRIDES=1. GKE services are internal: kubectl port-forward first, then use http://127.0.0.1:8080. Done when the deployed agent answers a prompt.
To register the agent with Gemini Enterprise or Agent Registry, call the Skill tool with google-agents-cli-publish. When the user names a Gemini Enterprise app, publish right after the dev deploy and in the prod pipeline (In CI/CD there).
이 스킬의 파일
skills/google-agents-cli-deploy/references/agent-runtime.mdskills/google-agents-cli-deploy/references/batch-inference.mdskills/google-agents-cli-deploy/references/cicd.mdskills/google-agents-cli-deploy/references/cloud-run.mdskills/google-agents-cli-deploy/references/cmek.mdskills/google-agents-cli-deploy/references/gateway.mdskills/google-agents-cli-deploy/references/gke.mdskills/google-agents-cli-deploy/references/terraform.md