Google Cloud Platform (GCP) Reference
Kip Landergren
(Updated: )
My cheat sheet for Google Cloud Platform covering terminology, common commands, and links to the most helpful documentation resources.
Contents
- Tooling
- Commands
- Docker Integration
- Pulling Image to GKE from GCR
- Creating a Cluster
- Connecting to Cluster
- Google Cloud Platform (GCP) Terminology
- External Links
Tooling
gcloud |
CLI tool for managing Google Cloud Platform resources |
gsutil |
CLI tool for managing Cloud Storage |
Commands
help
gcloud --help
info
gcloud info
config
View, set and unset properties used by the Google Cloud SDK. Reduces the amount of flags needing to be passe don other commands.
gcloud config --help
gcloud config list
gcloud config set project example-com
gcloud config set compute/region us-west2
gcloud config unset compute/region
iam
gcloud iam --help
gcloud iam roles --help
gcloud iam service-accounts --help
dns
gcloud dns --help
addresses
gcloud compute addresses --help
gcloud compute addresses list
gcloud compute addresses create example-com-static-ip
gcloud compute addresses create example-com-global-static-ip --global
gcloud compute addresses create example-com-regional-static-ip --region=us-west2
gcloud compute addresses delete example-com-static-ip
forwarding-rules
gcloud compute forwarding-rules --help
gcloud compute forwarding-rules list
gcloud compute forwarding-rules describe NAME
gcloud compute forwarding-rules delete NAME
Docker Integration
Register gcloud
as credential helper:
gcloud auth configure-docker
Tag local image:
docker tag LOCAL-IMAGE-NAME gcr.io/PROJECT-NAME/IMAGE-NAME:TAG
Push to GCR:
docker push gcr.io/PROJECT-NAME/IMAGE-NAME:TAG
Pull from GCR:
docker pull gcr.io/PROJECT-NAME/IMAGE-NAME:TAG
Pulling Image to GKE from GCR
For a newly created cluster, things should “just work” as the service account should be provisioned with permissions that allow read-only access to dev storage. If not, review the service account permissions and access policy on the bucket storing the images.
Quick steps:
- confirm image stored and accessible on gcr.io
- specify the <gcr.io> image in manifest, optionally including tag
- same project / same account? should “just work”
- not working? check service account permissions for https://www.googleapis.com/auth/devstorage.read_only
- still not working? consider setting bucket-level permissions
Creating a Cluster
Notes below are based on creating a cluster through the Cloud Console.
Kubernetes Versions: Standard and Advanced
“Advanced” has an improved SLA and reliability. More info in this blog post.
Regional vs Zonal
From the official documentation:
“A regional cluster provides a single static endpoint for the entire cluster and spreads your cluster's Pods across multiple zones of a given region. This allows you to access the cluster's control plane even during an outage or downtime involving one or more (but not all) individual zones.”
As of August 2019 you cannot switch a Zonal cluster to Regional. If you choose Zonal, the zone is permanent.
Master Version
Choose the Kubernetes version appropriate to your application and any dependencies it may have.
Node Pools
Select “More Options” to better customize.
Network Configuration
HTTP Load Balancing
If disabled
, default Ingress objects will not be created using Google Cloud Load Balancer. However, a network load balancer will still be provisioned via a forwarding-rule for any IP address to target-pool mapping. This will incur an hourly charge.
Connecting to Cluster
Copy the command from the Cloud Console button “Connect” to update your local kubeconfig file with appropriate credentials and endpoint information.
Generally of form:
gcloud container clusters get-credentials CLUSTER-NAME
Google Cloud Platform (GCP) Terminology
- address
- an IP address, may be ephemeral or reserved
- bucket
- a container for your objects; cannot be nested within another
- forwarding-rule
- directs traffic matching an address to a forwarding target, like a target-pool
- object
- the piece of data stored
- region
- a specific geographic location where your resources run
- target-pool
- load-balanced pool of virtual machine instances
- zone
- an isolated location within a region; name take form
<region>-<zone>
External Links
Reference
- Cloud IAM
- Regions and Zones
- Cloud DNS
- Load Balancing and Autoscaling
- Google Cloud Storage Documentation
- Forwarding Rules
- Official Kubernetes Engine Documentation