Yash Verma / Cloud runbook

GCP commands

25 commands from the cloud runbook. Fill in a placeholder once and every command uses it.

Authenticate with Google Cloud

Authorizes the gcloud CLI to access Google Cloud Platform with your user credentials.

gcloud auth login

auth, login

Set active GCP project

Sets the default project ID for all subsequent gcloud commands.

gcloud config set project <project-id>

project, config

Get GKE cluster credentials

Fetches cluster credentials for Google Kubernetes Engine and updates your local kubeconfig.

gcloud container clusters get-credentials <cluster-name> --region <region>

gke, kubernetes

List GCE VM instances

Lists all Google Compute Engine instances in the active project.

gcloud compute instances list

compute, vms

SSH into GCE instance

Securely connects to a Compute Engine virtual machine via Identity-Aware Proxy (IAP).

gcloud compute ssh <instance-name> --zone <zone> --tunnel-through-iap

ssh, iap, compute

Get project IAM policy

Fetches the complete IAM policy (roles and members) bound to the current project.

gcloud projects get-iam-policy <project-id>

iam, security

Sync local folder to GCS bucket

Synchronizes the contents of a local directory to a Google Cloud Storage bucket.

gcloud storage rsync ./my-folder gs://<bucket> --recursive

gcloud storage replaces gsutil, which Google now treats as legacy.

storage, gcs, sync

Calculate GCS bucket size

Shows the total size of a Cloud Storage bucket.

gcloud storage du gs://<bucket> --summarize --readable-sizes

storage, gcs, size

Run BigQuery SQL

Executes a standard SQL query directly against BigQuery from the command line.

bq query --use_legacy_sql=false 'SELECT * FROM `project.dataset.table` LIMIT 10'

bigquery, sql, data

Deploy to Cloud Run

Deploys a container image to Cloud Run as a fully managed serverless service.

gcloud run deploy <service-name> --image <image> --region <region>

Add --allow-unauthenticated only if the service should be public on the internet.

serverless, deploy, cloud-run

Access Secret Manager value

Retrieves the decoded payload of a secret stored in GCP Secret Manager.

gcloud secrets versions access latest --secret="<secret-name>"

Prints the secret in plain text to your terminal.

secrets, security

Publish Pub/Sub message

Publishes a test message to a Cloud Pub/Sub topic.

gcloud pubsub topics publish <topic-name> --message="Hello World"

pubsub, messaging

List VPC networks

Lists all VPC networks and their subnet modes in the project.

gcloud compute networks list

vpc, network

Set up Application Default Credentials

Authenticates your local environment so code can use GCP APIs natively.

gcloud auth application-default login

auth, adc

List Cloud Run services

Lists all deployed Cloud Run services in the active project.

gcloud run services list

cloud-run, serverless

Connect to Cloud SQL

Connects with the mysql or psql client, allowlisting your IP address for a few minutes.

gcloud sql connect <instance-name> --user=<user>

sql, database, connect

List firewall rules

Shows all firewall rules in the project.

gcloud compute firewall-rules list

firewall, network, security

Read Cloud Logging entries

Fetches the last 20 log entries from Cloud Logging.

gcloud logging read "resource.type=gce_instance" --limit 20 --format json

logging, monitoring

List Artifact Registry repos

Lists container image repositories in Artifact Registry.

gcloud artifacts repositories list --location=<region>

artifact-registry, docker

Deploy Cloud Function

Deploys a Python Cloud Function triggered by HTTP.

gcloud functions deploy <function-name> --gen2 --region=<region> --runtime=python312 --source=. --entry-point=main --trigger-http

Add --allow-unauthenticated only if the function should be public on the internet.

functions, serverless

List service accounts

Lists all service accounts in the project.

gcloud iam service-accounts list

iam, service-account

List persistent disks

Lists all persistent disks in the project.

gcloud compute disks list

compute, storage, disks

List Cloud DNS zones

Lists all managed DNS zones in the project.

gcloud dns managed-zones list

dns, zones

List GKE node pools

Lists node pools for a specific GKE cluster.

gcloud container node-pools list --cluster=<cluster-name> --region=<region>

gke, nodes, cluster

List billing accounts

Lists billing accounts you have access to.

gcloud billing accounts list

billing, cost