cloud-run-basics: Managing Cloud Run Services, Jobs, and Worker Pools with Agent Skills

Preface

Running HTTP APIs, scheduled batch processing, or persistent pull-based background tasks on Google Cloud typically involves checking documentation, piecing together gcloud parameters, and verifying IAM and image sources. Cloud Run offers three types of resources—Service, Job, and Worker pool—each with slightly different commands and prerequisites. When verbally asking Agents like Cursor to “deploy it for me,” models often overlook critical requirements such as listen addresses, $PORT, or build account permissions.

The following introduces the cloud-run-basics Skill from Google’s official repository. It encapsulates Cloud Run concepts, prerequisite APIs/roles, and deployment/troubleshooting steps for the three resource types into a SKILL.md, allowing Agents to execute procedures according to guidelines when needed.

What is This

cloud-run-basics is an Agent Skill in the google/skills repository (metadata version 1.0.0, category Serverless). It is designed for the Agent Skills ecosystem: acting as documentation rather than executable code, it teaches AI assistants when and how to operate Cloud Run.

The official description summarizes it as: managing Cloud Run services, jobs, and worker pools—deploying HTTP-responsive applications (services), tasks executed manually or on a schedule (jobs), and persistent background workers for pull-based workloads like Kafka, Pub/Sub pull, or RabbitMQ (worker pools).

Skill Source Path: skills/cloud/cloud-run-basics. The repository also contains references/ (core concepts, CLI, IAM, Terraform, MCP, etc.), which the Skill body points to.

Core Functions

The Skill body revolves around the three resource types of the Cloud Run fully managed platform, consistent with official product definitions:

  1. Services: Serve external traffic via stable HTTP endpoints, with stateless instances auto-scaling based on metrics; also handle events and function-like scenarios.
  2. Jobs: Parallelizable, manually triggered or scheduled, running until completion.
  3. Worker pools: Persistent background workers suitable for pull-based workloads (e.g., Kafka consumers, Pub/Sub pull, RabbitMQ consumers).

Beyond concepts, the Skill solidifies a set of practical operational contents (all sourced from the official SKILL.md):

  • Prerequisites: Enabling Cloud Run Admin API and Cloud Build API; listing required IAM roles and the command to bind roles/run.builder to the Cloud Build default service account.
  • Service Deployment: Container image deployment, source deployment (buildpacks / Dockerfile), and explanation of --no-build parameters for Preview source deployments.
  • Job: gcloud run jobs create / deploy, execute, and common flags (--tasks, --max-retries, --task-timeout, --parallelism, --execute-now, etc.).
  • Worker pool: gcloud run worker-pools deploy (image or --source .).
  • Deployment Troubleshooting: IAM issues, startup crashes and log queries, native dependencies, and trade-offs regarding --no-build.

For developers building Agent backends, Serverless is commonly used to handle tool calls or lightweight APIs; this Skill combines Google’s recommended CLI paths and key constraints, reducing the space for Agents to “guess commands.”

Installation and Enablement

The Skill is distributed as part of the google/skills package. The official installation method is the CLI documented at skills.sh:

npx skills add google/skills

Follow the prompts to select the Skill to install (you can select just cloud-run-basics), the target Agent, and the scope (project or global). If npx is not available in your environment, you must first install Node.js with npm/npx.

To update installed Skills:

npx skills update

Community indexes (such as awesome-agent-skills) list Cursor, Claude Code, Codex, GitHub Copilot, etc., as compatible Agents; specific mounting methods for each platform depend on their respective documentation. The google/skills repository handles selection and configuration uniformly via npx skills add; this article does not expand on product-specific paths not explicitly stated in the official repository.

After installation, simply describe your Cloud Run deployment or operational intent in a conversation. The Agent should load this Skill when matching tasks like “manage Cloud Run / deploy serverless apps” and follow its steps (local gcloud configuration and valid GCP project permissions are still required).

Typical Usage

The following examples are excerpted from the official Skill text. Replace placeholders and execute in an authorized project.

1. Enable APIs

gcloud services enable run.googleapis.com cloudbuild.googleapis.com --quiet

2. Deploy Cloud Run Service (Container Image)

gcloud run deploy SERVICE_NAME \
    --image IMAGE_URL \
    --region us-central1 \
    --allow-unauthenticated \
    --quiet

IMAGE_URL example: us-docker.pkg.dev/cloudrun/container/hello:latest. The Skill recommends using Artifact Registry; Docker Hub images have cache latency, so using Artifact Registry remote repositories is preferred for production.

Hard Rules (Marked as CRITICAL in the Skill): The process must listen on 0.0.0.0 (not just 127.0.0.1) and use the injected environment variable $PORT (default 8080); otherwise, the instance will fail during startup.

3. Deploy Service from Source (with Dockerfile)

gcloud run deploy SERVICE_NAME --source . --quiet

If a Dockerfile exists in the directory, Cloud Build constructs and deploys it in the cloud. If using buildpacks and requiring automatic base image updates, --base-image and --automatic-updates can be used (only supports Google buildpacks base images).

4. Create and Execute Job

Create:

gcloud run jobs create JOB_NAME --image IMAGE_URL OPTIONS --quiet

Or:

gcloud run jobs deploy JOB_NAME --image IMAGE_URL OPTIONS --quiet

Execute an existing Job:

gcloud run jobs execute JOB_NAME --quiet

To wait for execution to finish:

gcloud run jobs execute JOB_NAME --wait --region=REGION --quiet

5. Deploy Worker Pool

Image method:

gcloud run worker-pools deploy WORKER_POOL_NAME --image IMAGE_URL --quiet

Source code method:

gcloud run worker-pools deploy WORKER_POOL_NAME --source . --quiet

6. Check Logs on Startup Failure

The Skill suggests fetching logs immediately upon health check failure, for example:

gcloud logging read "resource.labels.service_name=SERVICE_NAME" --limit=20

For more detailed explanations on IAM, networking, and costs, refer to the references/ files in the Skill directory; the body also mentions that for product documentation gaps, one can search via the Developer Knowledge MCP search_documents tool.

Applicable Scenarios and Notes

Who is it for

  • Users already using or planning to use Google Cloud who want Agents to complete the creation and execution of the three Cloud Run resource types following official steps.
  • Teams deploying Agent tool services, batch processing, or message consumption to Serverless, needing a unified “API enablement → Roles → gcloud commands → Troubleshooting” workflow.

Usage Notes

  • The Skill is an operational guide and does not replace GCP billing, organization policies, or network security policies; if the project restricts unauthenticated calls, private service access methods must be tested according to Cloud Run documentation.
  • If deployment relies on Cloud Build, the roles/run.builder role must be granted to the build service account (the Skill provides the gcloud projects add-iam-policy-binding template).
  • --no-build source deployment is Preview, with many parameters, suitable for scenarios familiar with the runtime base image; for Node/Python native dependency compilation issues, the Skill suggests switching back to --source . to use buildpacks.
  • Service names must be unique within the same region and project and cannot exceed 49 characters; Job --tasks limit is 10000, and --task-timeout is up to 168 hours (1 hour for GPU tasks).

Conclusion

cloud-run-basics encapsulates the three resource types, CLI deployment paths, and common troubleshooting for Cloud Run into an Agent-readable Skill, serving as an official reference for “implementing serverless backends on GCP.” The installation entry is npx skills add google/skills. The Skill source code and reference documentation are available at: https://github.com/google/skills/tree/main/skills/cloud/cloud-run-basics.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye