agentleFS
kumaran-iskumaran-is/claude-code-onboarding/.claude/skills/adk-deploy-guide/SKILL.md

adk-deploy-guide

Skill36 starsChanged 6 months agoMITView on GitHub

MUST READ before deploying any ADK agent to Google Cloud — covers Cloud Run, Agent Engine, Vertex AI, event-driven agents, and ADK CI/CD pipelines. Use when deploying ADK agents to production, not for agent code patterns (use google-adk) or project scaffolding.

  • Reads credentials
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user which target fits their needs before proceeding.

    line 53
  2. Distinctive:

    No Makefile, Terraform, or Dockerfile required.

    line 59
  3. Distinctive:

    If prototype, first add Terraform/CI-CD files using the Agent Starter Pack CLI:

    line 123
  4. Distinctive:

    Ensure you're logged in to GitHub CLI:

    line 128

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

ADK Deployment Guide

Scaffolded project? Use make commands — they wrap Terraform, Docker, and deployment.

No scaffold? See Quick Deploy below. For production infrastructure, see the /scaffold-adk command or load the architecture-design skill for infrastructure planning.

Iron Law

NEVER create GCP resources manually via gcloud for production. Define all infrastructure in Terraform. Exception: quick experimentation only — console or gcloud for throwaway resources is fine.


Reference Files

FileContents
reference/agent-engine.mdAdkApp pattern, deploy.py CLI, session/artifact services, CI/CD differences
reference/cloud-run.mdDockerfile, session types, scaling defaults, networking, ingress, IAP
reference/event-driven.mdPub/Sub, Eventarc, BigQuery Remote Function trigger patterns
reference/terraform-patterns.mdCustom resources, IAM bindings, state management, importing resources

For agent code patterns and testing strategies, see google-adk skill. For evaluations and observability, see adk-eval-guide and adk-observability-guide skills.


Deployment Target Decision Matrix

CriteriaAgent EngineCloud Run
DeploymentSource-based, no DockerDockerfile + container image
ScalingManaged auto-scalingFully configurable (min/max instances)
Session stateNative VertexAiSessionServiceIn-memory (dev), Cloud SQL, or Agent Engine backend
Event-drivenNot supportedPub/Sub, Eventarc, BigQuery Remote Function via /invoke
Cost modelvCPU-hours + memory-hours (not billed when idle)Per-instance-second + min instance costs
Setup complexityLower — managed, purpose-built for agentsMedium — Dockerfile, Terraform, networking
Best forMinimal ops, managed infrastructureEvent-driven workloads, full infrastructure control

Ask the user which target fits their needs before proceeding.


Quick Deploy (ADK CLI)

No Makefile, Terraform, or Dockerfile required.

# Cloud Run
adk deploy cloud_run --project=PROJECT --region=REGION path/to/agent/

# Agent Engine
adk deploy agent_engine --project=PROJECT --region=REGION path/to/agent/

Both support --with_ui to deploy the ADK dev UI. Cloud Run accepts extra gcloud flags after --.


Process

  1. Gather requirements — target (Agent Engine vs Cloud Run), project ID, region, secrets needed
  2. Choose target — use the decision matrix above; ask if unclear
  3. Scaffold or write Terraform — run /scaffold-adk or manually write deployment/terraform/
  4. Configure secrets — use Secret Manager, not env vars, for API keys and credentials
  5. Deploy — make deploy (scaffolded) or adk deploy <target> (CLI)
  6. Verify — health check endpoint, test with curl or testing notebook, run load tests

Secret Manager

# Create
echo -n "YOUR_API_KEY" | gcloud secrets create MY_SECRET_NAME --data-file=-

# Update
echo -n "NEW_KEY" | gcloud secrets versions add MY_SECRET_NAME --data-file=-

# Agent Engine: pass at deploy time
make deploy SECRETS="API_KEY=my-api-key,DB_PASS=db-password:2"

Grant secretmanager.secretAccessor to app_sa (Cloud Run) or service-PROJECT_NUMBER@gcp-sa-aiplatform-re.iam.gserviceaccount.com (Agent Engine).


Documentation Sources

SourceURLPurpose
ADK Deploymenthttps://google.github.io/adk-docs/deploy/Official deployment docs
Cloud Runhttps://google.github.io/adk-docs/deploy/cloud-run/index.mdCloud Run specifics
Agent Enginehttps://google.github.io/adk-docs/deploy/agent-engine/index.mdAgent Engine specifics


Production Deployment — CI/CD Pipeline

Best for: Production applications, teams requiring staging → production promotion.

Prerequisites:

  1. Project must NOT be in a gitignored folder
  2. User must provide staging and production GCP project IDs
  3. GitHub repository name and owner

Steps:

  1. If prototype, first add Terraform/CI-CD files using the Agent Starter Pack CLI:
    uvx agent-starter-pack enhance . --cicd-runner github_actions -y -s
  2. Ensure you're logged in to GitHub CLI:
    gh auth login  # (skip if already authenticated)
  3. Run setup-cicd:
    uvx agent-starter-pack setup-cicd \
      --staging-project YOUR_STAGING_PROJECT \
      --prod-project YOUR_PROD_PROJECT \
      --repository-name YOUR_REPO_NAME \
      --repository-owner YOUR_GITHUB_USERNAME \
      --auto-approve \
      --create-repository
  4. Push code to trigger deployments

Key setup-cicd Flags

FlagDescription
--staging-projectGCP project ID for staging environment
--prod-projectGCP project ID for production environment
--repository-name / --repository-ownerGitHub repository name and owner
--auto-approveSkip Terraform plan confirmation prompts
--create-repositoryCreate the GitHub repo if it doesn't exist
--cicd-projectSeparate GCP project for CI/CD infrastructure. Defaults to prod project
--local-stateStore Terraform state locally instead of in GCS

Choosing a CI/CD Runner

RunnerProsCons
github_actions (Default)No PAT needed, uses gh auth, WIF-based, fully automatedRequires GitHub CLI authentication
google_cloud_buildNative GCP integrationRequires interactive browser authorization (or PAT + app installation ID for programmatic mode)

How Authentication Works (WIF)

Both runners use Workload Identity Federation (WIF) — GitHub/Cloud Build OIDC tokens are trusted by a GCP Workload Identity Pool, which grants cicd_runner_sa impersonation. No long-lived service account keys needed. Terraform in setup-cicd creates the pool, provider, and SA bindings automatically. If auth fails, re-run terraform apply in the CI/CD Terraform directory.

CI/CD Pipeline Stages

The pipeline has three stages:

  1. CI (PR checks) — Triggered on pull request. Runs unit and integration tests.
  2. Staging CD — Triggered on merge to main. Builds container, deploys to staging, runs load tests.

    Path filter: Staging CD uses paths: ['app/**'] — it only triggers when files under app/ change. If nothing happens after the first push after setup-cicd, this is why.

  3. Production CD — Triggered after successful staging deploy. May require manual approval before deploying to production.

    Approving: Go to GitHub Actions → the production workflow run → click "Review deployments" → approve the pending production environment. This is GitHub's environment protection rules.

IMPORTANT: setup-cicd creates infrastructure but doesn't deploy automatically. Push code to trigger the pipeline:

git add . && git commit -m "Initial agent implementation"
git push origin main

To approve production deployment:

# GitHub Actions: Approve via repository Actions tab (environment protection rules)

# Cloud Build: Find pending build and approve
gcloud builds list --project=PROD_PROJECT --region=REGION --filter="status=PENDING"
gcloud builds approve BUILD_ID --project=PROD_PROJECT

Service Account Architecture

Scaffolded projects use two service accounts:

  • app_sa (per environment) — Runtime identity for the deployed agent. Roles defined in deployment/terraform/iam.tf.
  • cicd_runner_sa (CI/CD project) — CI/CD pipeline identity (GitHub Actions / Cloud Build). Needs permissions in both staging and prod projects.

Troubleshooting

IssueSolution
Agent Engine deploy timeoutCheck if engine was created; manually populate deployment_metadata.json
403 on deploycicd_runner_sa missing deployment role or SA impersonation in target project
403 testing Cloud RunAdd Authorization: Bearer $(gcloud auth print-identity-token) header
Secret access deniedVerify secretAccessor granted to app_sa, not default compute SA
Cold starts slowSet min_instance_count > 0 in Cloud Run Terraform config
Resource already existsUse terraform import — see reference/terraform-patterns.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.