Skip to content

Cloud CLI: GCP

GCP commands from the Cloud CLI folder.

Index
5 items

GCP: Log in and set the project

Safe

Authenticate the CLI and set the default project.

gcloud auth login && gcloud config set project <project-id>
What each part does
  1. gcloud auth loginsign in via the browser
  2. &&continue only if login succeeded
  3. gcloud config set project <project-id>default project for later gcloud commands

Also known as: gcloud login · gcloud project

GCP: Get GKE cluster credentials

Safe

Adds the GKE cluster context to ~/.kube/config.

gcloud container clusters get-credentials <cluster> --region <region>
What each part does
  1. gcloud container clusters get-credentials <cluster>write the GKE cluster into ~/.kube/config and switch to it
  2. --region <region>for regional clusters; use --zone for zonal ones

Also known as: gke kubeconfig

GCP: Read recent error logs

Safe

Errors from Cloud Logging in the last hour across the project.

gcloud logging read 'severity>=ERROR' --freshness=1h --limit=50
What each part does
  1. gcloud logging readquery Cloud Logging
  2. 'severity>=ERROR'filter: ERROR, CRITICAL, ALERT, EMERGENCY
  3. --freshness=1honly entries from the last hour
  4. --limit=50return at most 50 entries

Also known as: stackdriver · cloud logging

GCP: Deploy a Cloud Run revision

Safe

Deploy a new image as a new revision and shift 100% traffic to it.

gcloud run deploy <service> --image <image> --region <region>
What each part does
  1. gcloud run deploy <service>create a new revision of the service (creates the service if missing)
  2. --image <image>container image, e.g. europe-docker.pkg.dev/proj/repo/app:1.4
  3. --region <region>region of the service

Also known as: cloud run deploy

GCP: Roll back Cloud Run traffic to a revision

Caution

Send all traffic back to a known good revision.

gcloud run services update-traffic <service> --to-revisions <revision>=100 --region <region>
What each part does
  1. gcloud run services update-traffic <service>change which revisions get traffic (no new deploy)
  2. --to-revisions <revision>=100send 100% of traffic to that revision
  3. --region <region>region of the service

Also known as: cloud run rollback

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…