Skip to content

Google Cloud SDK (Docker Kubernetes DevOps) Cheatsheet

Adonis Lee Villamor edited this page Apr 15, 2020 · 1 revision

Note: You must have installed the Google Cloud SDK tool to perform these

Commands

Docker registry

Add Google's Container Registry to your local docker setup

gcloud auth configure-docker

components

List installed components

gcloud components list

Install kubectl component (if you still have not)

gcloud components install kubectl

Remove kubectl component

gcloud components removekubectl

Projects (gcloud projects --help)

Get the list of projects

gcloud projects list

Set the default project and zone

gcloud config set project [PROJECT_ID]
gcloud config set compute/zone [COMPUTE_ENGINE_ZONE]

Compute zones (gcloud compute zones --help)

Get the valid zones list

gcloud compute zones list

Container Clusters (gcloud container clusters --help)

Create a new cluster

// format: gcloud container clusters create {cluster-name} --num-nodes={number of nodes to be created}
gcloud container clusters create guestbook --num-nodes=2

List the cloud clusters in your project

gcloud container clusters list

Get details about the cluster

gcloud container clusters describe {cluster-name}

Get credentials for a cluster

gcloud container clusters get-credentials {cluster-name}

Container Node Pools (gcloud container node-pools --help)

List all node pools in a cluster

// format: gcloud container node-pools list --cluster={cluster-name}
gcloud container node-pools list --cluster=sample-cluster

Kubectl in GCLOUD

to run kubectl in gcloud, make sure to have installed kubectl

// first run the following to see if kubectl component is already installed
gcloud components list
// if not install it
gcloud components install kubectl
// test by running some commands like the following
kubectl get pods

// NOTE: In case you get the following error. this is because none of the credentials for your specific clusters are loaded for kubernetes
/* Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it. */
/// run the following to fix
gcloud container clusters get-credentials {cluster-name}