GCP Associate Cloud Engineer Master Cheatsheet
GCP Associate Cloud Engineer Master Cheatsheet
Deploy applications
Exam Domains
pg. 1
SKILLCERTPRO
Get rid of responses that have fake info or other errors && Get
Eliminate
Rid of responses that conflict with the key question
Pick exactly the right number && select the best options or
Choose
eliminate the worst ones
Make sure your responses answer the key question && make
Validate
sure your responses don't conflict with any details
pg. 2
SKILLCERTPRO
Links
SRE Books
Regions Map
Network Map
Network Pricing
pg. 3
SKILLCERTPRO
Pricing Calculator
BeyondCorp
Account Set Up
Trial Account from GCP is pretty sweet. Links are below for more information.
Depending on how much data of yourself you have saved into your browser it
will be a bit of pain. Just make sure you add all you details properly
It might sound weird but you want to ensure that you use least privilege while
going about. Least Privilege
pg. 4
SKILLCERTPRO
dataset you specify. You can then access your billing data from BigQuery. -- GCP
Docs
o Delay is in hours.
To help you with project planning and controlling costs, you can set a budget.
Setting a budget lets you track how your spend is growing toward that
amount.
You can apply a budget to either a billing account or a project, and you can
set the budget at a specific amount or match it to the pervious month's
spend. You can also create alerts to notify billing administrators when
spending exceeds a percentage of your budget.
Billing IAM
o Use Case: This role has very restricted permissions, so you can grant it
broadly, typically in combination with Project Creator. These two roles
allow a user to create new project linked to the billing account on
which the role is granted.
pg. 5
SKILLCERTPRO
o The point here is to tightly control the access of who manages the
billing.
o Remember to enable 2FA and multi-step auth whenever you are given
the option for it.
Google Cloud Shell provides you with command-line access to your cloud resources
directly from your browser. You can easily manage your projects and resources
without having to install the Google Cloud SDK or other tools on your system. With
Cloud Shell the Cloud SDK gcloud CLI and other utilities you need are always
available, up to date and fully authenticated when you need them -- GCP Docs
Highlights
o gcloud, bq, kubectl, docker, npm/node, pip/python, ruby, vim, emacs, bash
Data Flows
aCloudGuru Lecture Video Links
Mental Models
pg. 6
SKILLCERTPRO
IT is all about Data flows. Try to link up in you mind, a mental model for how this
data flows through the cloud system and how you move data in systems that you
build on top of the cloud platform
Network Moving
Compute Processing
Storage Remembering
Mental Models
A simplified representation of reality, which is ....
Systems combine
Basic Services
pg. 7
SKILLCERTPRO
In this lab I included a ./lab-content/ directory that has a empty text file and
some memes I enjoy to upload, edit permissions, move and delete in the
cloud. Feel Free to use them as you like.
o Also get used to googling for the google docs on for the google
commands
pwd
ls
gsutil ls
gsutil ls gs://storage-lab-console/
gsutil ls gs://storage-lab-console/**
gsutil mb --help
gsutil ls gs://storage-lab-cli/
gsutil cp README-cloudshell.txt gs://storage-lab-cli/
gsutil ls gs://storage-lab-cli/
gsutil ls gs://storage-lab-cli/
gsutil ls -a gs://storage-lab-cli/
gsutil rm gs://storage-lab-cli/README-cloudshell.txt
gsutil ls gs://storage-lab-cli/
gsutil ls -a gs://storage-lab-cli/
pg. 8
SKILLCERTPRO
gcloud Syntax
gcloud Properties
gcloud Configurations
pg. 9
SKILLCERTPRO
In general more powerful than the console but less powerful than REST API
Alpha and Beta versions are available via "gcloud alpha" or "gcloud beta"
Basic Systnax
gcloud <global flags> <service/product> <group/area> <command> <flags>
<parameters>
Examples:
Global Flags
--help
-h
--project <ProjectId>
--account <Account>
--filter -- sometimes better than using grep
--format
Configuration Properties
Values entered once and used by any command that needs them
pg. 10
SKILLCERTPRO
Configurations
Can maintain groups of settings and switch between them
o other column list account, project, region, zone, and the name of the
config
Helpful links
Filters in gcloud
Helpful Commands
# Check the elected project
gcloud config list
pg. 11
SKILLCERTPRO
whoami
hostname
curl api.ipify.org
# Connect to the VM
ssh externalipaddress
gcloud compute ssh myhappyvm
pg. 12
SKILLCERTPRO
Helpful links
Creating Instances
Preemptible Instances
Service Accounts
pg. 13
SKILLCERTPRO
Even the SSH keys from the console verses the gcloud cloudshell CLI are
different
You can set the scope for the vm to have API wide access
also note that the SSH keys via the console are generated with an expiry
What is Security
Helpful Links
Information Security - Wikipedia
Security by Design
Definition
Information security, sometimes shortened to InfoSec, is the practice of preventing
unauthorized access, use, disclosure, disruption, modification, inspection, recording
or destruction of information.... Its primary focus is the balanced protection of the
confidentiality, integrity and availability of data (also know=n as the CIA triad) while
maintaining a focus on efficient policy implementation, all without hampering
organization productivity.
-- Wikipedia
pg. 14
SKILLCERTPRO
Security Products
Security Features
Security Mindset
Least privilege
Fail Securely
Identity
Identity hierarchy
o Google Groups
Can use Google Cloud Directory Sync (GCDS) to pull from LDAP
o Permissions
o Roles
o Bindings
pg. 15
SKILLCERTPRO
GSC ACLS
Billing Management
Billing export
o Billing Export
o BigQuery
Resource Hierarchy
Resource
Project
Folder
Organization
Docs
Resource hierarchy for access control
pg. 16
SKILLCERTPRO
Helpful Links
IAM Overview
Understanding Roles
Predefined Roles
Permissions
A permission allows you to perform certain action
Examples:
o pubsub.subscriptions.consume
o pubsub.topics.publish
Roles
A role is a collection of Permissions to use or manage GCP Resources
o viewer is read-only
o For the exam read through the list of roles for each product! --Think
about why each exists
pg. 17
SKILLCERTPRO
App
roles/ Read/Write/Modify access to all application
Engine
appengine.AppAdmin configuration and settings.
Admin
App
roles/ Read-only access to all application
Engine
appengine.appViewer configurations and settings.
Viewer
App
roles/ Engine Read-only access to all configuration
appengine.codeViewer Code settings, and deployed source code
Viewer
Members
Can be:
pg. 18
SKILLCERTPRO
Groups
"Every group has unique email address that is associated with the group."
o Example: one group for each department, all those in group for all staff
"gcloud add-iam-policy-binding"
Policies
pg. 19
SKILLCERTPRO
Use groups!
Can use get-iam-policy, edit the JSON/YAML file, and set-iam-policy back
o are simpler, less work, and less error-prone (than editing the yaml or
json)
IAM FAQ
Helpful Links
Overview of Cloud Billing Access Control
Billing Accounts
A billing account represents some way to pay for GCP service usage
pg. 20
SKILLCERTPRO
Billing Account
Create new self-serve billing accounts. Org
Creator
Billing Account Manage billing accounts (but not create them Billing
Admin ). Account
Billing
Billing Account User Link projects to billing accounts
Account
pg. 21
SKILLCERTPRO
o to determine eligibility
Eligibility depends on
o Account age
o country
Networking in GCP
Routing Overview
About Software Defined Networking
Helpful Links
OSI Model of Networking - Webopedia
Routing - Wikipedia
Links
pg. 22
SKILLCERTPRO
Latency Reduction -- solved with Cross Region Load Balancing with Global
Anycast IPs
System Design -- Solved by using HTTP(S) Load Balancer (with URL Map)
pg. 23
SKILLCERTPRO
Unicast vs Anycast
Unicast: there is only one unique device in the world that can handle this;
send it there
Anycast: there are multiple devices that could handle this; send it to any one;
but ideally the closest
Layer 4 vs Layer 7
TCP is usually called Layer 4
Therefore:
o Chunky -- DNS queries often cached and reused for huge client sets
o sticky -- DNS lookups "lock on" and refreshing per request has a high
cost
o Not robust -- relies on the client always doing the right thing
pg. 24
SKILLCERTPRO
Helpful Links
AcloudGuru -- Primer on Subnets and CIDRs
o Not just resource to resource -- also manges the doors to outside & peers
o all subnets can reach all others -- globally without any need for VPNs
o routes are global and apply by Instance level tags, not by subnet
firewall rules (global) further filter data flow that would otherwise route
o all firewall rule are global and apply by Instance-level tags or service
account
Part 1
VPC Documentation
Part 2
pg. 25
SKILLCERTPRO
Part 3
Firewall Rules Overview
Challenge Lab
A Lab Challenge built on the previous step
Two-tier setup: frontend and back, each auto scaled across 2+ zones
Frontend:
Backend:
pg. 26
SKILLCERTPRO
My Solution
Start with 2 sets of managed instance groups like in the first lab
o use https://cidr.xyz/
pg. 27
SKILLCERTPRO
o HTTP == 80
o HTTPS == 443
o SSH == 22
o ICMP == NO PORT
o RDP == 3389
o SQL == 1443
o MySQL == 3306
o Postgres == 5432
New range must contain old range (i.e. old range must be a subset)
Shared VPC
Shared VPC
pg. 28
SKILLCERTPRO
Helpful links
GKE Overview
GKE Concepts
Cluster Architecture
Pods
Deployments
StatefulSets
DaemonSets
GKE Storage
Introduction
Learn Kubernetes
Course Outline
K8s Big Picture
K8s Networking
K8s Storage
K8s deployments
pg. 29
SKILLCERTPRO
A Kubernetes Primer
Cloud Native Apps! Cloud Native on Wikipedia
REST
CRUD
Kubernetes Objects
containers are wrapped up in a Pod!
Deploy
pg. 30
SKILLCERTPRO
o scaling
o rolling updates
Getting a cluster
I will be using GCP!
Just go in to GCP
App Architecture
Theory
Kubernetes objects can spin up cloud resources
secrets is an object
Sample App
I forked this from nigelpoulton
https://github.com/DRpandaMD/k8s-sample-apps
Kubernetes Networking
service discovery!
endpoints added and removed from network based on active scaling up and
down
pg. 31
SKILLCERTPRO
they are in a declarative format. which is great for K8s and Documentation.
Service Types
Cluster Ip is the default:
o gets own IP
NodePort:
LoadBalancer
pg. 32
SKILLCERTPRO
o Node network
o Pod network
"kube-proxy"
IPTABLES Mode:
IPVS Mode
Networking Demo
kubectl get nodes used to list nodes in the cluster
kubectl apply -f ./ping-deploy.yml creates a deployment based on the .yml
kubectl get deploy gets the deployment object here its just pingtest
kubectl get pods -o wide shows the wide landscape of how the pods are set
against the nodes
kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}' shows another
output of just the CIDR blocks the nodes are sitting on.
kubectl exec -it pingtest-6bcdfcdc5b-8t6zg bash just like docker this will
connect into said pod with bash (these pods will change)
run apt-get install iputils-ping curl dnsutils iproute2 -y to install some
utilities that the base container image does not come with and will needed to
run some tests
o you will have to run apt-get update FIRST!!
inside the pod you can ping the other pods it will work
pg. 33
SKILLCERTPRO
o if you don't remember (Like I did) just install the tools again on the new pod
curl hello-svc:8080 which is the format of <SERVICE_NAME: Pod_Port>
o this will dump out the HTML text of the pod
curl <Any_Node_IP>:30001 which is the format of <NODE_IP: NODE_PORT>
o This will ALSO dump out the html text of the pod
copy and paste the external IP and put it into a browser and the web page
should render
Kubernetes Storage
o Standards based
o pluggable backend
o Rich API
o Speed?
o Replication?
o Resiliency
o ...etc
pg. 34
SKILLCERTPRO
Containers Storage Interface puts the storage into the hands of the Persistent
Volume Subsystem.
o Standard
o SSD
GCEPersistentDisk PlugIn
pg. 35
SKILLCERTPRO
clean up by:
o check the deployment, pods, pvc, and pv and it should all be cleaned
up
o deployments!!
Demo
Examine the directory code and dockerfile
I went ahead and made some changes to his code and made it my own and
deployed the deployment and the web-service
for clean up you will want to make sure you kill the deployment and services
made in kubernetes
Kubernetes Deployments
deployments wrap up your pods
make your changes in the deployment post it against the API server then stick
it back into git
o rolling updates :
pg. 36
SKILLCERTPRO
maxSurge: 1 -- will have one extra pod than the desired state
during the update
o This will roll out new pods with the new version and kill off the old
pods one by one until all pods in the desired state of 3 have the new
version. -- This will keep your app up while rolling the update
minReadySeconds: 300 will give 5 minutes between each new pod -- this
helps give time to ensure the pods stand up
Deployment Demo
kubectl get nodes
kubectl version -o yaml
kubectl apply -f deploy.yml
kubectl get deployment test --watch
kubectl describe deployment test
kubectl get rs -- rs here means replica set
kubectl rollout history deployment test
kubectl apply -f deploy.yml --record
kubectl rollout undo deploy test
Cluster AutoScaler
HPA Demo
to match up what Nigel has, i set my cluster to autoscale min 3 nodes max 6
nodes
pg. 37
SKILLCERTPRO
Cluster Autoscaler
make sure you have your pods listed in the yaml with resource requests!
check your specific cloud for support (luckily GCP is on top of it)
via HTTPS
Schema validation
RBAC
o GA since 1.8
o Deny-by-default
pg. 38
SKILLCERTPRO
Authentication
Kubernetes does not do users
Service Accounts
o do happen in Kubernetes
o managed by kubernetes
Authorization
Basically : who can perform which actions on which resources
out of the box K8s has Default Users -- its how you been doing everything in
the cluster as it stands
You will need to create some Roles & RoleBindings for least privilege
o role is namespaced
o what you can do is create ClusterRoles then in the RoleBinding you can
add namespaces to them.
o That way you can make a few ClusterRoles but get granular in
the RoleBinding
o This prevents you from doing extra work with roles and assigning them
pg. 39
SKILLCERTPRO
mutating
validating
RBAC Demo
Github Code
RBAC Recap
Here is an overview I snipped from the mad lads over at acloudguru
StatefulSet -
pg. 40
SKILLCERTPRO
PodSecurityPolicy
What is Next
The Kubernetes Book
Community KubeCon
serverice meshes
prometheus
API
Services Breadth
Google Cloud Products
Compute
Google Compute Engine
pg. 41
SKILLCERTPRO
Storage
Local SSD
Persistent Disk
Cloud FileStore
Cloud Storage(GCS)
Databases
Cloud SQL
Cloud Spanner
BigQuery
Cloud BigTable
Datastore
Datastore Queries
Firebase DBs
Data Transfer
Data Transfer Appliance
pg. 42
SKILLCERTPRO
External Networking
Google Domains
Cloud DNS
Static IPs
Cloud CDN
Internal Networking
Virtual Private Cloud
Cloud VPN
Dedicated Interconnect
Cloud Router
CDN Interconnect
Machine Learning / AI
Note: ACG calls it the ML Engine at some point google renamed it the 'AI Platform'
pg. 43
SKILLCERTPRO
Dialogflow
Cloud Pub/Sub
Cloud Dataprep
Cloud Dataproc
Cloud Dataflow
Dataflow Shuffle
Cloud Datalab
Jupyter Notebook
Cloud Genomics
Roles
pg. 44
SKILLCERTPRO
Service Accounts
Cloud Identity
Resource Manager
pg. 45