Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)33k · #8738

cloud-run-basics

Skill này làm gì

Skill này giải thích và hướng dẫn sử dụng Google Cloud Run, nền tảng chạy code của bạn mà bạn không phải quản lý máy chủ. Skill dành cho người xây dựng hoặc lưu trữ ứng dụng trên Google Cloud.

Khi nào nên dùng

  • ✓Khi bạn muốn đưa một ứng dụng web hoặc API lên Google Cloud Run.
  • ✓Khi bạn cần một tác vụ chạy theo lịch hoặc chạy một lần khi có yêu cầu.
  • ✓Khi bạn có một worker nền đọc từ hàng đợi và phải luôn chạy.

Liên kết skill

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/cloud-run-basics/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/cloud-run-basics/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Giúp tôi triển khai ứng dụng web lên Google Cloud Run để nó hoạt động trên internet.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill hướng dẫn các bước bật dịch vụ Google Cloud cần thiết, thiết lập quyền truy cập, và tạo một trong ba loại tài nguyên: service, job hoặc worker pool.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Cloud Run Basics

Cloud Run is a fully managed application platform for running your code, function, or container on top of Google's highly scalable infrastructure. It abstracts away infrastructure management, providing three primary resource types:

  1. Services: Responds to HTTP requests sent to a unique and stable endpoint, using stateless instances that autoscale based on a variety of key metrics, also responds to events and functions.
  2. Jobs: Executes parallelizable tasks that are executed manually, or on a schedule, and run to completion.
  3. Worker pools: Handles always-on background workloads such as pull-based workloads, for example, Kafka consumers, Pub/Sub pull queues, or RabbitMQ consumers.

Prerequisites

  1. Enable the Cloud Run Admin API and Cloud Build APIs:

    gcloud services enable run.googleapis.com cloudbuild.googleapis.com --quiet
    
  2. If you are under a domain restriction organization policy restricting unauthenticated invocations for your project, you will need to access your deployed service as described under Testing private services.

Required roles

You need the following roles to deploy your Cloud Run resource:

  • Cloud Run Admin (roles/run.admin) on the project
  • Cloud Run Source Developer (roles/run.sourceDeveloper) on the project
  • Service Account User (roles/iam.serviceAccountUser) on the service identity
  • Logs Viewer (roles/logging.viewer) on the project

Cloud Build automatically uses the Compute Engine default service account as the default Cloud Build service account to build your source code and Cloud Run resource, unless you override this behavior.

For Cloud Build to build your sources, grant the Cloud Build service account the Cloud Run Builder (roles/run.builder) role on your project:

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member=serviceAccount:SERVICE_ACCOUNT_EMAIL_ADDRESS \
    --role=roles/run.builder \
    --quiet

Replace PROJECT_ID with your Google Cloud project ID and SERVICE_ACCOUNT_EMAIL_ADDRESS with the email address of the Cloud Build service account.

Deploy a Cloud Run service

You can deploy your service to Cloud Run by using a container image or deploy directly from source code using a single Google Cloud CLI command.

CRITICAL RULE: Any deployed code MUST listen on 0.0.0.0 (not 127.0.0.1) and use the injected $PORT environment variable (defaults to 8080), or it will crash on boot.

Deploy a container image to Cloud Run

Cloud Run imports your container image during deployment. Cloud Run keeps this copy of the container image as long as it is used by a serving revision. Container images are not pulled from their container repository when a new Cloud Run instance is started.

Supported container images

You can directly use container images stored in the Artifact Registry, or Docker Hub. Google recommends the use of Artifact Registry since Docker Hub images are cached for up to one hour.

You can use container images from other public or private registries (like JFrog Artifactory, Nexus, or GitHub Container Registry), by setting up an Artifact Registry remote repository.

You should only consider Docker Hub for deploying popular container images such as Docker Official Images or Docker Sponsored OSS images. For higher availability, Google recommends deploying these Docker Hub images using an Artifact Registry remote repository.

To deploy a container image, run the following command:

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

Replace the following:

  • SERVICE_NAME: the name of the service you want to deploy to. Service names must be 49 characters or less and must be unique pe
Câu hỏi thường gặp

Service và job khác nhau thế nào?

Service trả lời các yêu cầu web tại một địa chỉ ổn định. Job chạy một tác vụ đến khi xong, khi có yêu cầu hoặc theo lịch.

Worker pool dùng để làm gì?

Dùng cho công việc nền luôn hoạt động, lấy tin nhắn từ hàng đợi, như các consumer của hàng đợi.

Tôi có cần bật gì trước khi triển khai không?

Có. Cloud Run Admin API và Cloud Build API phải được bật trong dự án của bạn.

Chi tiết

Mô tả gốc của tác giả

Manages Cloud Run services, jobs, and worker pools. Use when you need to deploy applications responding to HTTP requests (services), run event-triggered or scheduled tasks (jobs), or handle always-on pull-based background processing (worker pools).

repo: davila7/claude-code-templates

Độ phổ biến

Sao GitHub
33k
Vị trí xếp hạng
#8738
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự