liminfo

GCP Reference

Free reference guide: GCP Reference

26 results

About GCP Reference

The GCP CLI Reference is a searchable command cheat sheet for Google Cloud Platform's three primary command-line tools: gcloud, gsutil, and bq. It covers five service categories — Compute (VM instances, Cloud Run, Cloud Functions), Storage (Cloud Storage bucket creation, file upload/download, rsync), BigQuery (queries, dataset creation, data loading and export), Kubernetes (GKE cluster creation, kubectl integration), IAM (service accounts, policy bindings, custom roles), and Networking (VPC, firewall rules, static IPs, Cloud DNS, load balancer forwarding rules).

Google Cloud Platform is widely used by cloud engineers, site reliability engineers (SREs), data engineers, and DevOps teams building scalable infrastructure. The gcloud CLI is the primary interface for provisioning compute resources and managing services, while gsutil handles object storage operations and bq provides a fast interface to BigQuery's petabyte-scale data warehouse. This reference is particularly helpful when scripting deployments, writing CI/CD pipelines, or onboarding new team members to GCP workflows.

Every entry shows the exact command syntax with real flag values and a multi-line shell example that can be adapted directly in terminal or scripts. Commands are organized into six browsable categories so engineers can quickly jump to the relevant service area. Both standard and filtered variations are shown — for example gcloud compute instances list --filter="status=RUNNING" and gsutil mb with storage class and region flags — to address the most common real-world usage patterns.

Key Features

  • Compute commands: gcloud compute instances create/list/ssh, gcloud run deploy, gcloud functions deploy
  • Storage commands: gsutil mb, gsutil cp (upload/download/recursive), gsutil ls, gsutil rsync
  • BigQuery commands: bq query (standard SQL), bq mk --dataset, bq load (CSV from GCS), bq extract
  • GKE and Kubernetes: gcloud container clusters create/get-credentials, kubectl apply -f, kubectl get pods
  • IAM commands: service account creation, project policy binding, custom role creation, service account authentication
  • Networking commands: VPC creation, firewall rules, static IP reservation, Cloud DNS zones, load balancer forwarding rules
  • Real shell examples with actual flag values — zone, region, machine-type, image-family, --allow-unauthenticated
  • Covers both gcloud (resource management), gsutil (object storage), and bq (analytics) CLIs in one place

Frequently Asked Questions

What is the GCP CLI Reference and what does it cover?

This reference covers the three main GCP command-line tools: gcloud for managing Compute Engine, Cloud Run, GKE, IAM, and networking resources; gsutil for Cloud Storage bucket and object operations; and bq for running BigQuery queries and managing datasets. It is designed for engineers who need quick lookup of exact command syntax and flag names.

How do I create a GCP VM instance with gcloud?

Use gcloud compute instances create followed by the instance name and flags: --zone to specify the zone, --machine-type for the instance size (e.g. e2-medium), --image-family and --image-project to select the OS image. For example: gcloud compute instances create my-vm --zone=us-central1-a --machine-type=e2-medium --image-family=debian-11 --image-project=debian-cloud.

What is the difference between gsutil cp and gsutil rsync?

gsutil cp copies specific files or directories to or from Cloud Storage, including recursive copies with the -r flag. gsutil rsync synchronizes a local directory with a GCS bucket directory, copying only files that differ and optionally deleting files in the destination that do not exist in the source — similar to rsync for local filesystems.

How do I deploy a containerized application to Cloud Run?

Use gcloud run deploy with the service name, --image flag pointing to your container image in gcr.io or Artifact Registry, --platform=managed for fully managed Cloud Run, --region for the deployment region, and --allow-unauthenticated to permit public access. The command handles provisioning, scaling, and TLS automatically.

How do I run a BigQuery query from the command line?

Use bq query --use_legacy_sql=false followed by your standard SQL query in single quotes. Reference tables using the backtick-quoted syntax: `project.dataset.table`. Add LIMIT to control result size. For large result sets, consider using bq query --destination_table to write results to another table.

How do I grant a service account permissions in GCP?

First create the service account with gcloud iam service-accounts create, then bind a predefined or custom role to the project using gcloud projects add-iam-policy-binding. Specify the member as serviceAccount:name@project.iam.gserviceaccount.com and the role using the --role flag, such as roles/storage.admin.

How do I connect kubectl to a GKE cluster?

Run gcloud container clusters get-credentials with the cluster name and --zone flag. This command fetches the cluster credentials and updates your local kubeconfig file, allowing kubectl commands to target the GKE cluster. After running this, kubectl get pods, kubectl apply -f, and other kubectl commands will work against your GKE cluster.

How do I create a firewall rule to allow HTTP and HTTPS traffic?

Use gcloud compute firewall-rules create with a rule name, --network to specify the VPC, --allow=tcp:80,tcp:443 to permit HTTP and HTTPS, and --source-ranges=0.0.0.0/0 to allow traffic from any IP. Restrict source ranges to specific CIDR blocks for production environments to improve security.