gcloud

Google Cloud SDK are tools and libraries for interacting with Google Cloud products and services. Examples include: “gcloud”, “gsutil”, and “bq” among others.

Install

Install Google cloud SDK using your favourite method, e.g. Brew or download macOS 64-bit(arm64, Apple M1 silicon) directly from google

brew install --cask google-cloud-sdk
# Note: if you see failures (e.g., 503) during the google-cloud-sdk installation, you may need to set your python proxy and re-run the command. e.g.,
# export HTTP_PROXY="http://user:password@hostname:port"
# export HTTPS_PROXY="http://user:password@hostname:port"

Configuration

Log in to Google Cloud and select your project, region, etc.

# initialize the SDK
gcloud init # --console-only if in a remote shell

Link gcloud CLI with your GCP Project

# list configurations 
gcloud config configurations list
gcloud info
# create new configurations
gcloud config configurations create env-sumo
# switch configurations
gcloud config configurations activate env-sumo

# set auth for your `env-sumo` 
gcloud auth login
gcloud auth list

# select your project_id from `gcloud projects list`
export PROJECT_ID=ngx-starter-kit
# set default account 
export ACCOUNT=<my_gcp_email@gmail.com>
# Set default region from `gcloud compute regions list`
export COMPUTE_REGION=us-west1
# select default zone from `gcloud compute zones list --filter=region:us-west1`
export COMPUTE_ZONE=us-west1-a

gcloud config set project $PROJECT_ID
gcloud config set account $ACCOUNT
gcloud config set compute/region $COMPUTE_REGION
gcloud config set compute/zone $COMPUTE_ZONE

Usage

gcloud has an interactive shell if you wish to use it:

Network

(Optional) VPC network

Docker Artifact Registry

Create GCP Docker Artifact Registry

Cloud Run

Deploy on Cloud Run

Last updated

Was this helpful?