gcloud CLI
gcloud CLI
The gcloud CLI is the official command-line tool for interacting with Google Cloud Platform (GCP). It lets you create, manage, and monitor cloud resources directly from your terminal.
1. Install gcloud CLI
You can install the Google Cloud SDK (which includes gcloud) from:
- https://cloud.google.com/sdk/docs/install
2. Initialize gcloud
gcloud init
This logs you in and lets you select your GCP project and default settings.
3. Common gcloud Commands
Authenticate
gcloud auth login
Set Active Project
gcloud config set project PROJECT_ID
Compute Engine
gcloud compute instances list
gcloud compute instances create my-vm --zone=us-central1-a
gcloud compute ssh my-vm
Cloud Storage
gcloud storage buckets list
gcloud storage cp localfile.txt gs://my-bucket/
Cloud Run
gcloud run deploy my-service --source=. --region=us-central1
Kubernetes (GKE)
gcloud container clusters get-credentials my-cluster
kubectl get pods
App Engine
gcloud app deploy
4. Useful Config Commands
gcloud config list
gcloud config set compute/region asia-south1
gcloud config set compute/zone asia-south1-a
5. Help & Documentation
gcloud --help
gcloud compute --help
gcloud compute instances --help
You can use --help with any command to see all its options.