Skip to content

Instantly share code, notes, and snippets.

@jesusvazquez
Last active January 25, 2021 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jesusvazquez/011a713045fa2f023eebcfd806bb1033 to your computer and use it in GitHub Desktop.
Save jesusvazquez/011a713045fa2f023eebcfd806bb1033 to your computer and use it in GitHub Desktop.

Gcloud Cheatsheet

Configurations

Create them using             gcloud init
Which config is set           gcloud info
List configurations           gcloud config configurations list
Change between them           gcloud config configuration activate <config>
Set project in current config gcloud config set project <project>

Auth

Activate from key file        gcloud auth activate-service-account --key-file=<file>

Service accounts

# Generate Key for service account  
gcloud iam service-accounts keys create ~/key.json --iam-account <name>@<project>.iam.gserviceaccount.com

Kubernetes Credentials

# Generate credentials for kubectl in GKE
gcloud container clusters get-credentials staging --zone=us-central1-a

Kubectl

# Create namespace
kubectl create -f namespace.yml

# Create quota
kubectl create -f resourcequota-compute-resources.yml --namespace=team

# Describe quota
kubectl describe quota --namespace=team1

# Make yourself an admin
kubectl create clusterrolebinding cluster-admin-binding \
  --clusterrole cluster-admin \
  --user $(gcloud config get-value account)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment