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
brewinstall--caskgoogle-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 SDKgcloudinit# --console-only if in a remote shell
Link gcloud CLI with your GCP Project
# list configurations gcloudconfigconfigurationslistgcloudinfo# create new configurationsgcloudconfigconfigurationscreateenv-sumo# switch configurationsgcloudconfigconfigurationsactivateenv-sumo# set auth for your `env-sumo` gcloudauthlogingcloudauthlist# 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-agcloudconfigsetproject $PROJECT_IDgcloudconfigsetaccount $ACCOUNTgcloudconfigsetcompute/region $COMPUTE_REGIONgcloudconfigsetcompute/zone $COMPUTE_ZONE
Usage
gcloud has an interactive shell if you wish to use it:
gcloudcomponentsinstallbetagcloudbetainteractive# Testing The CLI Setupgcloudauthlogingcloudauthlist# List the sdk configurationgcloudconfiglistgcloudinfo# To install or remove components at your current SDK, run:gcloudcomponentsinstallCOMPONENT_IDgcloudcomponentsremoveCOMPONENT_ID
gcloudartifactsrepositoriescreatedocker--repository-format=docker \--location=us-west1 --description="Docker repository"gcloudartifactsrepositorieslist# hook it up to GCP `Artifact Registry` so you can push containers:gcloudauthconfigure-dockerus-west1-docker.pkg.dev# after you publish a docker image, check with:gcloudartifactsdockerimageslistus-west1-docker.pkg.dev/ngx-starter-kit/docker