Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Google Cloud: gcloud run commands

Here’s a comprehensive guide to all gcloud run subcommands with examples and explanations:


📦 1. Deploying Services

gcloud run deploy

Create or update a fully-managed service.

gcloud run deploy SERVICE_NAME \
  --image=gcr.io/my-project/my-image:tag \
  --platform=managed \
  --region=asia-northeast1 \
  --allow-unauthenticated
  • Builds and deploys a new revision.
  • Automatically handles traffic, IAM settings, and service creation.
    (stackoverflow.com)

🛠️ 2. Managing Services

gcloud run services list

List all Cloud Run services in a region.

gcloud run services list \
  --platform=managed \
  --region=asia-northeast1 \
  --format="table(metadata.name,status.url)"

gcloud run services describe

Show detailed info (config, traffic, URL, latest revision, etc.).

gcloud run services describe my-service \
  --platform=managed \
  --region=asia-northeast1

🔍 3. Managing Revisions

gcloud run revisions list

List all revisions of a service.

gcloud run revisions list \
  --platform=managed \
  --region=asia-northeast1 \
  --filter="metadata.labels.service=my-service" \
  --format="table(metadata.name,metadata.creationTimestamp)"

gcloud run revisions describe

Get detailed metadata of a specific revision.

gcloud run revisions describe my-service-00005-xyz \
  --platform=managed \
  --region=asia-northeast1

👥 4. IAM & Permissions

gcloud run services add-iam-policy-binding

Grant roles to members.

gcloud run services add-iam-policy-binding my-service \
  --member=user:me@gmail.com \
  --role=roles/run.invoker \
  --platform=managed \
  --region=asia-northeast1

Likewise: remove-iam-policy-binding, get-iam-policy, set-iam-policy.


⚙️ 5. Updating Services

gcloud run services update

Apply config changes to a service (without redeploying code).

gcloud run services update my-service \
  --platform=managed \
  --region=asia-northeast1 \
  --concurrency=100 \
  --memory=512Mi

📋 6. Metadata Inspection

  • To view YAML or JSON output: gcloud run services describe my-service \ --platform=managed \ --region=asia-northeast1 \ --format=json
  • To extract specific fields: # Service URL: gcloud run services describe my-service \ --platform=managed \ --region=asia-northeast1 \ --format="value(status.url)" # Container image: gcloud run services describe my-service \ --platform=managed \ --region=asia-northeast1 \ --format="value(spec.template.spec.containers[0].image)"

🧪 7. Jobs (Cloud Run jobs)

gcloud run jobs list

List all jobs.

gcloud run jobs list \
  --platform=managed \
  --region=asia-northeast1 \
  --format="table(metadata.name, status.lastRunState)"

gcloud run jobs describe

Describe a job.

gcloud run jobs describe my-job \
  --platform=managed \
  --region=asia-northeast1

gcloud run jobs execute

Run the job now.

gcloud run jobs execute my-job \
  --platform=managed \
  --region=asia-northeast1

🔁 8. Alpha/Beta Commands

Additional flags and features exist in beta or alpha:

  • gcloud beta run deploy
  • gcloud beta run services update
  • gcloud alpha run ...

Install via:

gcloud components install beta
gcloud beta run deploy ...

Shows future enhancements and experimental options not in GA (reddit.com, youtube.com, cloud.google.com, reddit.com, stackoverflow.com, cloud.google.com)


🛠️ 9. Global Options

Common flags available to all commands:

  • --project=PROJECT_ID
  • --platform=[managed|gke]
  • --region=REGION
  • --format=[json|table|yaml|value]
  • --filter=...
  • --verbosity=[debug|info]
  • --async (non-blocking execution)

✅ TL;DR: Quick Reference

CategoryCommandUse Case
Deploygcloud run deployCreate/update service with container or source
Managegcloud run services list/describeView services and metadata
Update Configgcloud run services updateChange service settings without redeploy
Revisionsgcloud run revisions list/describeInspect immutable deployment snapshots
IAMadd/remove/get-iam-policy-bindingManage access permissions
Jobsgcloud run jobs list/describe/executeRun batch jobs with Cloud Run
Metadata format--format=Get output as JSON/YAML/fields
Filtering--filter=Query services or revisions dynamically
Async execution--asyncDon’t wait for operations to complete

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x