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#
- Products
- Tooling
- gcloud
- Docker Integration
- Pulling Image to GKE from GCR
- Creating a Cluster
- Connecting to Cluster
- External Links
- Terminology
Products#
Network Services#
Cloud DNS#
- prefer naming zones with suffix -dns-zone, e.g. internal-dns-zone
Tooling#
| gcloud | CLI tool for managing Google Cloud Platform resources |
| gsutil | CLI tool for managing Cloud Storage |
gcloud#
components#
gcloud help components
gcloud components update
gcloud components reinstall
compute#
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
instances#
gcloud compute instances create \
--labels component=frontend
gcloud compute instances update \
--update-labels component=frontend
gcloud compute instances update \
--remove-labels component
gcloud compute instances describe
gcloud compute instances list \
--filter labels.component=frontend
gcloud compute instances list \
--filter="labels.component=frontend AND labels.environment=production AND status=RUNNING" \
--format="value(name)"
config#
View, set, and unset properties used by the Google Cloud SDK. Reduces the amount of flags needing to be passed on 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
dns#
gcloud dns --help
help#
gcloud --help
iam#
gcloud iam --help
gcloud iam roles --help
gcloud iam service-accounts --help
info#
gcloud info
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
External Links#
Reference#
- Cloud IAM
- Regions and Zones
- Cloud DNS
- Load Balancing and Autoscaling
- Google Cloud Storage Documentation
- Forwarding Rules
- Official Kubernetes Engine Documentation
Tooling#
Terminology#
- address#(term address)
- 1.
An IP address, may be ephemeral or reserved.
Related:
- bare metal instance#(term bare metal instance)
- 1.
Instance without a hypervisor installed. Ends in suffix -metal.
- blue-green deployment#(term blue-green deployment)
- 1.
- bucket#(term bucket)
- 1.
A container for your objects; cannot be nested within another.
Related:
- CFT (Cloud Foundation Toolkit)#(term Cloud Foundation Toolkit)(term CFT)
- 1.
- ClickOps#(term ClickOps)
- 1.
The practice of managing infrastructure through clicking GUIs rather than Infrastructure as Code.
- Compute Engine instance#(term Compute Engine instance)(term compute instance)(term instance)
- 1.
- canary deployment#(term canary deployment)
- 1.
- custom image#(term custom image)
- 1.
- Fabric FAST#(term Fabric FAST)
- 1.
- folder#(term folder)
- 1.
- forwarding-rule#(term forwarding-rule)
- 1.
Directs traffic matching an address to a forwarding target, like a target-pool.
Related:
- guest#(term guest)
- 1.
The virtualized environment running on top of the hypervisor.
Related:
- guest environment#(term guest environment)
- 1.
The daemons and OS hooks which poll the metadata server and translate GCP state into linux primitives.
- host#(term host)
- 1.
The physical machine and software running the hypervisor.
Related:
- IaC (Infrastructure as Code)#(term Infrastructure as Code)(term IaC)
- 1.
- IAM binding#(term IAM binding)
- 1.
- IAM principal#(term IAM principal)
- 1.
- IAM role#(term IAM role)
- 1.
- label#(term label)
- 1.
A key value pair used to organize resources; flows through to billing.
Related:
- metadata#(term metadata)
- 1.
the information accessible through metadata.google.internal
- N-tier application architecture#(term N-tier application architecture)
- 1.
enterprise software term just describing layer to an application (e.g. “database tier” and “web server tier”). useful for conceptually grouping resources.
- network tag#(term network tag)
- 1.
Key added to resource for use in networking products (like firewalls)
Related:
- OS login#(term OS login)
- 1.
- object#(term object)
- 1.
The piece of data stored.
Related:
- Principle of Least Privilege#(term Principle of Least Privilege)
- 1.
Give subjects no more than necessary to perform a job.
- Public OS Image#(term Public OS Image)
- 1.
gcloud compute images list - region#(term region)
- 1.
A specific geographic location where your resources run (e.g. us-west1)
Related:
- role#(term role)
- 1.
RBAC meaning
- SA (service account)#(term service account)(term default service account)(term SA)
- 1.
- SDN (software defined network)#(term software defined network)(term SDN)
- 1.
- Separation of Duties#(term Separation of Duties)
- 1.
Allow no role to perform all transactions of a given set.
Example:
Transactions “open a charge on an account” and “approve a charge on an account” would be assigned to two separate roles.
This has basis in preventing fraud.
- service agent#(term service agent)
- 1.
- tag#(term tag)
- 1.
A key value pair used to manage access to resources; integrated with IAM policies.
Related:
- target-pool#(term target-pool)
- 1.
Load-balanced pool of virtual machine instances.
Related:
- transaction#(term transaction)
- 1.
RBAC meaning
- VPC (virtual private cloud)#(term virtual private cloud)(term VPC)
- 1.
- VPC-SC#(term Virtual Private Cloud Service Controls)(term VPC-SC)
- 1.
- virtual machine (VM)#(term virtual machine)(term VM)
- 1.
A computer whose resources—which would otherwise be hardware the operating system interacts with—are virtualized.
Related:
- zone#(term zone)
- 1.
An isolated location within a region; zone name takes the form <region>-<zone suffix> (e.g. zone us-west1-a is within region us-west1)
Related: