Google Cloud Platform – Associate Cloud Engineer
Certification Notes
Getting Started – Google Cloud and regions/zones
1. Advantages of Cloud Computing:
a) Instead of investing money ahead of time, you are paying rent that you can change in any
month.
a. Benefit for massive economies of scale, there are millions of servers from many cloud
providers, so the deals are competitive for us as a customer.
b. No more capacity guessing since it all scales with your needs
c. No need to spend money on running and maintaining data centres and staff.
d. Possibility to go global and deploy an application to multiple regions around the world with a
click of a button
2. Zones – how to achieve high availability in the same region – enter zones.
Each Region has three or more zones. They have increased availability and fault tolerance within
same region. In google language – each zone has one or more discrete clusters. Cluster is a distinct
physical infrastructure that is housed in a data centre. Zones in a region are connected through
low-latency links. This means if a region is in Dallas, Oregon, North America it may have zones us-
west-a, us-west-b, etc. but they may be localized in different parts of the city, region.
Google Compute Engine
1. Google Compute Engine (GCE)
a. In corporate data centres, apps are deployed to physical servers. In case we want to deploy
application in the cloud, we must rent virtual servers. Virtual servers in GCP are called
Virtual Machines and the Google Compute Engine (GCE) is the service in Google Cloud
Platform to provision and manage virtual machines.
b. Its features include:
It helps to create and manage lifecycle of Virtual Machine instances (VM).
Load balancing and autoscaling for multiple VM instances – so in case of having a
lot of users using the application we may want to increate the number of instances.
Attaching storage like hard drives and run operating systems.
Managing network connectivity and configuration, e.g., assigning IP address to VM.
2. Compute Engine Machine Family
There are different families and types of hardware available to run your workloads on.
Machine Families:
a. General Purpose (E2, N2, N2D, N1) – Best price-performance ratio. Used for web and
application servers, small-medium databases, dev environments.
b. Memory Optimized (M2, M1) – Ultra high memory workloads. Used for large in-memory
databases and in-memory analytics.
c. Compute Optimized (C2) – Compute intensive workloads. Used for gaming applications e.g.
Compute Engine Machine Types:
E2-standard-2, E2-standard-4, E2-standard-8… etc., where: standard - type of workload, 2 –
number of CPUs.
There is a possibility to choose one of many images of operational systems to install and run on
VM. We can distinguish 2 types of Images: Public Images, provided and maintained by Google or
Open-source communities and Custom Images – created by us.
3. Internal and External IP Addresses
, External (Public) IP Addresses are internet addressable. Internal (Private) IP Addresses are internal
to a corporate network. You cannot have two resources with same public IP address; however, two
different corporate networks can have resources with same internal IP address.
4. Assigning static IP Address to our VM.
Search box -> “External Static addresses” -> Reserve a static address -> fill in mandatory fields ->
Reserve -> Assign to the VM.
(Remember that region of the static address must coincide with the region of the VM)
5. Simplifying VM HTTP server setup
It is possible to reduce the number of steps in creating an VM instance and setting up a HTTP
server by using some of these options: creating a start-up script, instance template, custom image.
a. Start-up script – during the creation of the VM instance we can expand an additional
option called “Management, security, disks, networking, sole tenancy” and go to Automation
section and then Start-up scripts.
Exemplary Start-up script:
#!/bin/bash
apt update
apt -y install apache2
echo “Hello world from $(hostname) > /var/www/html/index.html
b. Instance Template – possibility to define machine type, image, labels, start-up scripts and
other properties. Used to create VM instances and managed instance groups. It cannot be
updated, to make a change, copy an existing template and modify it. Image family can be
specified so the latest non-deprecated version of the family is used. To create instance
template, you have to:
Compute Engine –> Virtual Machines –> Instance templates –> Create instance template ->
fill in mandatory fields.
Then on the newly created template, 3 dots -> Create VM
c. Custom image – image with OS patches and software pre-installed. Can be created from a
VM instance, persistent disk, another image or a file in Cloud Storage. Use option to
deprecate old images and specify replacement image. To create an image, you have to:
Turn off instance that is running with specific disk to create an image from.
Compute Engine –> Storage -> Disks -> 3 dots on specific instance -> Create Image ->
check & fill in mandatory fields -> Create
Then to check the image go to Storage -> Images -> Refresh the view to see new Image
Then to create VM instance 3 dots -> Create instance or by creating a new instance from
Instance Template and change “Boot disk” option.
Optimizing Costs and Performance in GCP
1. Sustained use discounts
Automatic discounts are applied for running VM instances for significant portion of the billing
month. For example, if you use N1, N2 machine types for more than 25% of a month, you get a 20-
50% discount. This is applicable for instances created by Google Kubernetes Engine and Compute
Engine but does not apply on certain machine types (E2 and A2).
2. Committed use discounts
For workloads with predictable resource needs. Commitment lasts for 1 or 3 years, and the discount
is up to 70% depending on machine type and GPUs. Applicable for instances created by Google
Kubernetes Engine and Compute Engine. Does not apply to VMs created by App Engine flexible and
Dataflow.
To ask for a committed use discount go to Compute Engine -> Virtual Machines -> Committed use
discounts.
,3. Preemptible VM Instances
Short-lived cheaper (up to 80%) compute instances. They can be stopped by GCP at any time
within 24 hours. Instances get 30 second warnings before action to save. Pre-empt VM’s are well
choice if applications are fault tolerant, project is cost sensitive, and workload is not immediate.
Restrictions: Not always available, no SLA and cannot be migrated to regular VMs, no automatic
restarts. Preemptibility can be switched on during the creation of the VM instance.
4. Google Compute Engine – Billing
Machine rent is billed by the second of usage (after a minimum of 1 minute). No billing when
compute instance is stopped, however it will be billed for any storage attached with it.
Recommendation – create billing alerts by going to Billing -> Budgets & alerts -> Create budget.
By creating budget, it is possible to specify target amount of money that after exceeded –
notification alert will appear. Alert may appear after exceeding thresholds that can be set at the
user’s discretion as well as the kind of notification to be sent.
5. Live Migration & Availability Policy
While host system needs to be updated due to software or a hardware change your VM instance
might be migrated to another host in the same zone. It does not change any attributes or
properties of the VM and works without downtime. On host maintenance options can be changed
during the process of creation VM Instance.
Gcloud for Associate Cloud Engineer
1. Gcloud Command Line Interface
CLI to interact with Google Cloud Resources, most GCP services like Compute Engine, Managed
Instance Groups, Databases and many more can be managed from CLI using Gcloud. It is possible
to create, delete, update and read existing resources and perform actions like deployments as well.
Though some services have specific CLI tools:
a. Cloud Storage – gsutil
b. Cloud BigQuery – bq
c. Cloud Bigtable – cbt
d. Kubernetes – kubectl
Gcloud is part of Google Cloud SDK – it is required to have Python installed. Cloud Shell also
provides the functions of the Gcloud.
Gcloud init – initialize or reinitialize Gcloud, Authorize Gcloud to use your user account
credentials, setup configuration includes current project, default zone etc.
Gcloud config list – lists all properties of the active configuration.
Gcloud config list core/account – write out only account property from core section
Gcloud config list compute/region – write out only region property from compute section
Gcloud config set sets the specified property in your active configuration
Gcloud config set core/project VALUE
Gcloud config set compute/region VALUE
Gcloud config set compute/zone VALUE
Gcloud config set core/verbosity VALUE(debug)
So, the general syntax is like that – GCLOUD CONFIG SET SECTION/PROPERTY, where:
, Core, compute – SECTIONS
Project, region, zone – PROPERTIES
Specifying core is optional as it is the default section. To get more details use Gcloud config set
–-help. The opposite command is Gcloud config unset.
2. Gcloud – Managing Multiple Configurations
If you are working on multiple projects from the same machine, you may execute commands using
different configurations.
Sample commands:
Gcloud config configurations list – lists all the available configurations and says which
one is active.
Gcloud config configurations create [name] – creates a new configuration with name.
Gcloud config configurations activate [name] – sets the active configuration.
Gcloud config configurations describe [name] – says the details about the specific
configuration.
3. Gcloud command structure
The general structure for Gcloud commands is – GCLOUD GROUP SUBGROUP ACTION, where:
GROUP – config/compute/container/dataflow/functions/iam …
SUBGROUP – instances/images/instance-templates/machine-types/regions/zones
ACTION – create/list/start/stop/describe
Examples:
Gcloud compute machine-types list
Gcloud compute machine-types list –-filter=”zone:us-central1-b”
Gcloud compute machine-types list –-filter=”zone:( us-central1-b Europe-west1-d )”
4. Gcloud compute instances command syntax
Gcloud compute instances create [name] - creating compute instances, with available options:
-machine-type (default type is n1-standard-1 – Gcloud compute machines-types list)
-custom-cpu, --custom-memory, -custom-vm-type(n1/n2) (--custom-cpu 6 –-custom-memory
3072MB –-custom-vm-type n2)
-image, –image-family, -source-snapshot, -source-instance-template, -source-
machine-image
-service-account, -no-service-account
-zone=us-central1-b
-tags (List of tags – allow network firewall rules and routes to be applied to VM instances)
-preemptible
-restart-on-failure (default), -no-restart-on-failure, -maintenance-policy(
MIGRATE(default)/TERMINATE)
-bot-disk-size, -boot-disk-type, -boot-disk-auto-delete (default) –no-boot-disk-auto-
delete
-delete-protection, -no-deletion-protection (default)
-metadata/metadata-from-file startup-script/start-script-url
-network, -subnet –network-tier (PREMIUM (default), STANDARD)
-accelerator=”type=nvidia-tesla-v100,count=8” –metadata=”install-nvidia-
driver=True” (GPU)
The all options available with Gcloud Compute instances may be read on google cloud
documentation website.
Gcloud CLI also offers setting up default regions and zones on computing instances. There are 3
options to do so:
Option #1 (Centralized Configuration): Gcloud compute project-info add-metadata –
metadata=[google-compute-default-zone=ZONE]
Option #2 (Local Gcloud Configuration): Gcloud config set compute/region REGION
Option #3 (Command Specific): --zone or --region in the command
Certification Notes
Getting Started – Google Cloud and regions/zones
1. Advantages of Cloud Computing:
a) Instead of investing money ahead of time, you are paying rent that you can change in any
month.
a. Benefit for massive economies of scale, there are millions of servers from many cloud
providers, so the deals are competitive for us as a customer.
b. No more capacity guessing since it all scales with your needs
c. No need to spend money on running and maintaining data centres and staff.
d. Possibility to go global and deploy an application to multiple regions around the world with a
click of a button
2. Zones – how to achieve high availability in the same region – enter zones.
Each Region has three or more zones. They have increased availability and fault tolerance within
same region. In google language – each zone has one or more discrete clusters. Cluster is a distinct
physical infrastructure that is housed in a data centre. Zones in a region are connected through
low-latency links. This means if a region is in Dallas, Oregon, North America it may have zones us-
west-a, us-west-b, etc. but they may be localized in different parts of the city, region.
Google Compute Engine
1. Google Compute Engine (GCE)
a. In corporate data centres, apps are deployed to physical servers. In case we want to deploy
application in the cloud, we must rent virtual servers. Virtual servers in GCP are called
Virtual Machines and the Google Compute Engine (GCE) is the service in Google Cloud
Platform to provision and manage virtual machines.
b. Its features include:
It helps to create and manage lifecycle of Virtual Machine instances (VM).
Load balancing and autoscaling for multiple VM instances – so in case of having a
lot of users using the application we may want to increate the number of instances.
Attaching storage like hard drives and run operating systems.
Managing network connectivity and configuration, e.g., assigning IP address to VM.
2. Compute Engine Machine Family
There are different families and types of hardware available to run your workloads on.
Machine Families:
a. General Purpose (E2, N2, N2D, N1) – Best price-performance ratio. Used for web and
application servers, small-medium databases, dev environments.
b. Memory Optimized (M2, M1) – Ultra high memory workloads. Used for large in-memory
databases and in-memory analytics.
c. Compute Optimized (C2) – Compute intensive workloads. Used for gaming applications e.g.
Compute Engine Machine Types:
E2-standard-2, E2-standard-4, E2-standard-8… etc., where: standard - type of workload, 2 –
number of CPUs.
There is a possibility to choose one of many images of operational systems to install and run on
VM. We can distinguish 2 types of Images: Public Images, provided and maintained by Google or
Open-source communities and Custom Images – created by us.
3. Internal and External IP Addresses
, External (Public) IP Addresses are internet addressable. Internal (Private) IP Addresses are internal
to a corporate network. You cannot have two resources with same public IP address; however, two
different corporate networks can have resources with same internal IP address.
4. Assigning static IP Address to our VM.
Search box -> “External Static addresses” -> Reserve a static address -> fill in mandatory fields ->
Reserve -> Assign to the VM.
(Remember that region of the static address must coincide with the region of the VM)
5. Simplifying VM HTTP server setup
It is possible to reduce the number of steps in creating an VM instance and setting up a HTTP
server by using some of these options: creating a start-up script, instance template, custom image.
a. Start-up script – during the creation of the VM instance we can expand an additional
option called “Management, security, disks, networking, sole tenancy” and go to Automation
section and then Start-up scripts.
Exemplary Start-up script:
#!/bin/bash
apt update
apt -y install apache2
echo “Hello world from $(hostname) > /var/www/html/index.html
b. Instance Template – possibility to define machine type, image, labels, start-up scripts and
other properties. Used to create VM instances and managed instance groups. It cannot be
updated, to make a change, copy an existing template and modify it. Image family can be
specified so the latest non-deprecated version of the family is used. To create instance
template, you have to:
Compute Engine –> Virtual Machines –> Instance templates –> Create instance template ->
fill in mandatory fields.
Then on the newly created template, 3 dots -> Create VM
c. Custom image – image with OS patches and software pre-installed. Can be created from a
VM instance, persistent disk, another image or a file in Cloud Storage. Use option to
deprecate old images and specify replacement image. To create an image, you have to:
Turn off instance that is running with specific disk to create an image from.
Compute Engine –> Storage -> Disks -> 3 dots on specific instance -> Create Image ->
check & fill in mandatory fields -> Create
Then to check the image go to Storage -> Images -> Refresh the view to see new Image
Then to create VM instance 3 dots -> Create instance or by creating a new instance from
Instance Template and change “Boot disk” option.
Optimizing Costs and Performance in GCP
1. Sustained use discounts
Automatic discounts are applied for running VM instances for significant portion of the billing
month. For example, if you use N1, N2 machine types for more than 25% of a month, you get a 20-
50% discount. This is applicable for instances created by Google Kubernetes Engine and Compute
Engine but does not apply on certain machine types (E2 and A2).
2. Committed use discounts
For workloads with predictable resource needs. Commitment lasts for 1 or 3 years, and the discount
is up to 70% depending on machine type and GPUs. Applicable for instances created by Google
Kubernetes Engine and Compute Engine. Does not apply to VMs created by App Engine flexible and
Dataflow.
To ask for a committed use discount go to Compute Engine -> Virtual Machines -> Committed use
discounts.
,3. Preemptible VM Instances
Short-lived cheaper (up to 80%) compute instances. They can be stopped by GCP at any time
within 24 hours. Instances get 30 second warnings before action to save. Pre-empt VM’s are well
choice if applications are fault tolerant, project is cost sensitive, and workload is not immediate.
Restrictions: Not always available, no SLA and cannot be migrated to regular VMs, no automatic
restarts. Preemptibility can be switched on during the creation of the VM instance.
4. Google Compute Engine – Billing
Machine rent is billed by the second of usage (after a minimum of 1 minute). No billing when
compute instance is stopped, however it will be billed for any storage attached with it.
Recommendation – create billing alerts by going to Billing -> Budgets & alerts -> Create budget.
By creating budget, it is possible to specify target amount of money that after exceeded –
notification alert will appear. Alert may appear after exceeding thresholds that can be set at the
user’s discretion as well as the kind of notification to be sent.
5. Live Migration & Availability Policy
While host system needs to be updated due to software or a hardware change your VM instance
might be migrated to another host in the same zone. It does not change any attributes or
properties of the VM and works without downtime. On host maintenance options can be changed
during the process of creation VM Instance.
Gcloud for Associate Cloud Engineer
1. Gcloud Command Line Interface
CLI to interact with Google Cloud Resources, most GCP services like Compute Engine, Managed
Instance Groups, Databases and many more can be managed from CLI using Gcloud. It is possible
to create, delete, update and read existing resources and perform actions like deployments as well.
Though some services have specific CLI tools:
a. Cloud Storage – gsutil
b. Cloud BigQuery – bq
c. Cloud Bigtable – cbt
d. Kubernetes – kubectl
Gcloud is part of Google Cloud SDK – it is required to have Python installed. Cloud Shell also
provides the functions of the Gcloud.
Gcloud init – initialize or reinitialize Gcloud, Authorize Gcloud to use your user account
credentials, setup configuration includes current project, default zone etc.
Gcloud config list – lists all properties of the active configuration.
Gcloud config list core/account – write out only account property from core section
Gcloud config list compute/region – write out only region property from compute section
Gcloud config set sets the specified property in your active configuration
Gcloud config set core/project VALUE
Gcloud config set compute/region VALUE
Gcloud config set compute/zone VALUE
Gcloud config set core/verbosity VALUE(debug)
So, the general syntax is like that – GCLOUD CONFIG SET SECTION/PROPERTY, where:
, Core, compute – SECTIONS
Project, region, zone – PROPERTIES
Specifying core is optional as it is the default section. To get more details use Gcloud config set
–-help. The opposite command is Gcloud config unset.
2. Gcloud – Managing Multiple Configurations
If you are working on multiple projects from the same machine, you may execute commands using
different configurations.
Sample commands:
Gcloud config configurations list – lists all the available configurations and says which
one is active.
Gcloud config configurations create [name] – creates a new configuration with name.
Gcloud config configurations activate [name] – sets the active configuration.
Gcloud config configurations describe [name] – says the details about the specific
configuration.
3. Gcloud command structure
The general structure for Gcloud commands is – GCLOUD GROUP SUBGROUP ACTION, where:
GROUP – config/compute/container/dataflow/functions/iam …
SUBGROUP – instances/images/instance-templates/machine-types/regions/zones
ACTION – create/list/start/stop/describe
Examples:
Gcloud compute machine-types list
Gcloud compute machine-types list –-filter=”zone:us-central1-b”
Gcloud compute machine-types list –-filter=”zone:( us-central1-b Europe-west1-d )”
4. Gcloud compute instances command syntax
Gcloud compute instances create [name] - creating compute instances, with available options:
-machine-type (default type is n1-standard-1 – Gcloud compute machines-types list)
-custom-cpu, --custom-memory, -custom-vm-type(n1/n2) (--custom-cpu 6 –-custom-memory
3072MB –-custom-vm-type n2)
-image, –image-family, -source-snapshot, -source-instance-template, -source-
machine-image
-service-account, -no-service-account
-zone=us-central1-b
-tags (List of tags – allow network firewall rules and routes to be applied to VM instances)
-preemptible
-restart-on-failure (default), -no-restart-on-failure, -maintenance-policy(
MIGRATE(default)/TERMINATE)
-bot-disk-size, -boot-disk-type, -boot-disk-auto-delete (default) –no-boot-disk-auto-
delete
-delete-protection, -no-deletion-protection (default)
-metadata/metadata-from-file startup-script/start-script-url
-network, -subnet –network-tier (PREMIUM (default), STANDARD)
-accelerator=”type=nvidia-tesla-v100,count=8” –metadata=”install-nvidia-
driver=True” (GPU)
The all options available with Gcloud Compute instances may be read on google cloud
documentation website.
Gcloud CLI also offers setting up default regions and zones on computing instances. There are 3
options to do so:
Option #1 (Centralized Configuration): Gcloud compute project-info add-metadata –
metadata=[google-compute-default-zone=ZONE]
Option #2 (Local Gcloud Configuration): Gcloud config set compute/region REGION
Option #3 (Command Specific): --zone or --region in the command