05 Virtual Machines
05 Virtual Machines
Virtual Machines
Google Cloud Associate Cloud Engineer
● Section Overview:
○ Compute Engine Overview
○ VM Options:
■ Image
■ Disk
■ Compute
○ VM Lifecycle
○ Compute Pricing Considerations
○ Common VM Actions
Google Cloud Associate Cloud Engineer
Compute Engine
Overview
Google Cloud Associate Cloud Engineer
Kubernetes
IaaS Container
Engine Any Cluster
PaaS Workloads
Kubernetes
IaaS Container
Engine Any Cluster
PaaS Workloads
Kubernetes
IaaS Container
Engine Any Cluster
PaaS Workloads
Kubernetes
IaaS Container
Engine Any Cluster
PaaS Workloads
Kubernetes
IaaS Container
Engine Any Cluster
PaaS Workloads
Kubernetes
IaaS Container
Engine Any Cluster
PaaS Workloads
● Compute
○ Each virtual CPU (vCPU) is implemented as a
single hardware multithread on one of the available
CPU processors.
○ Different generations of Compute Engine will have
different Intel CPU chips available (and different
costs).
Google Cloud Associate Cloud Engineer
● Compute
○ For applications that work better on GPUs,
Compute Engine also has a variety of NVIDIA
GPU options available for use.
○ TPU (Tensor Processing Units) for specialized
deep learning tasks are also available.
Google Cloud Associate Cloud Engineer
● Compute
○ You can also specify the RAM (Random Access
Memory) available to the VM instance.
○ Very high memory VMs are available (e.g. 3.75
TB RAM) but be aware of their price!
Google Cloud Associate Cloud Engineer
● Throughput Bandwidths
○ Network scales to 2 Gb per second (Gbps) per
vCPU.
○ Max of 32 Gbps with 16 vCPU or 100 Gbps with
V100, T4, and A100 GPUs.
Google Cloud Associate Cloud Engineer
● Disk Options
○ Standard
■ Spinning hard disk drive
○ SSD
■ Solid State Drives
○ Local SSD
■ Gone once instance is stopped or terminated.
Google Cloud Associate Cloud Engineer
● Networking
○ Default, Auto, Custom Networks
○ Firewall Rules
○ Load Balancing
○ Subnetwork Connections
Google Cloud Associate Cloud Engineer
● Review:
○ We discussed the VM options on Google Cloud
and went over some key components when
creating a new Compute Engine instance.
Google Cloud Associate Cloud Engineer
● Up Next:
○ We’ll have a deeper discussion on Images for your
VM instance.
Google Cloud Associate Cloud Engineer
Image Options
Google Cloud Associate Cloud Engineer
● Public Image:
○ Linux
■ CentOS, CoreOS, Debian, Ubuntu, and more.
○ Windows
■ Windows Server
■ SQL Server Pre-Installed on Windows
Google Cloud Associate Cloud Engineer
● Public Image:
○ Google, 3rd Party, and Premium Images are
available as well.
○ For example, a “Deep Learning on Linux” OS can
be provided with common machine learning
libraries installed and optimized for Intel.
Google Cloud Associate Cloud Engineer
● Public Image:
○ Be aware that certain premium images may have
an increased pricing structure and charge per
minute.
○ Review your VM pricing forecast after selecting
the Image and remember to explore the
marketplace.
Google Cloud Associate Cloud Engineer
● Custom Image:
○ You can create a custom image by pre-installing
software for your VM instance.
Google Cloud Associate Cloud Engineer
● Custom Image:
○ You can also import images from your own
premises, workstations, or even other cloud
providers.
○ GCP also offers a variety of Image management
features.
Google Cloud Associate Cloud Engineer
Multiple disk
Yes No No No
backup
● Review:
○ We explored the variety of options available for
Images when creating a VM instance and the
ability to create backups with a machine image.
Google Cloud Associate Cloud Engineer
● Up Next:
○ We’ll dive deeper into disk options when creating
a VM instance.
Google Cloud Associate Cloud Engineer
Disk Options
Google Cloud Associate Cloud Engineer
● Boot Disk
○ Every VM comes with a single root persistent disk
■ Bootable
● Can be attached to a VM and VM can boot
from it.
■ Durable
● Can “survive” a VM termination.
Google Cloud Associate Cloud Engineer
● Boot Disk
○ For durability beyond the VM termination, disable
the option:
■ “Delete boot disk when instance is deleted”
Google Cloud Associate Cloud Engineer
● Persistent Disk
○ Attached to the VM through the network interface
allowing for snapshots which are “in the moment”
incremental backups.
○ Users can choose between HDD or SSD for better
performance (with costs).
Google Cloud Associate Cloud Engineer
● Persistent Disk
○ Disks can be resized even if already attached to a
VM and running.
○ Can be attached to multiple VMs in a “read only”
mode.
Google Cloud Associate Cloud Engineer
● Persistent Disk
○ GCP encrypts all data at rest by default.
○ GCP also manages the encryption key for you, but
does give you the option to have customer
managed or customer supplied keys as well.
Google Cloud Associate Cloud Engineer
● Persistent Disk
○ There are several options for disks available.
○ More info:
■ cloud.google.com/compute/docs/disks
Google Cloud Associate Cloud Engineer
Efficient and Efficient and Cost-effective Cost-effective Fast and Fast and Highest High Affordable
reliable block reliable block and reliable block and reliable block reliable block reliable block performance performance object storage
storage storage with storage storage with storage storage with persistent block local block
synchronous synchronous synchronous storage option storage
replication replication across replication
across two two zones in a across two
zones in a region zones in a
region region
Google Cloud Associate Cloud Engineer
Efficient and Efficient and Cost-effective Cost-effective Fast and Fast and Highest High Affordable
reliable block reliable block and reliable block and reliable block reliable block reliable block performance performance object storage
storage storage with storage storage with storage storage with persistent block local block
synchronous synchronous synchronous storage option storage
replication replication across replication
across two two zones in a across two
zones in a region zones in a
region region
Google Cloud Associate Cloud Engineer
● Local SSD
○ Physically attached to the VM
■ Lower Latency
■ Higher Throughput (at higher cost)
■ VM Specific
■ Data does not survive a stop or termination
Google Cloud Associate Cloud Engineer
● RAM Disk
○ You can use tmpfs command to use RAM disks.
○ You can allocate some of this memory to create a
RAM disk with exceptionally low latency and high
throughput.
○ RAM disks work well when your application
expects a file system structure and cannot simply
store its data in memory.
Google Cloud Associate Cloud Engineer
● RAM Disk
○ RAM disks alone do not provide any storage
redundancy or flexibility, so it is best to use RAM
disks in combination with other instance storage
options.
Google Cloud Associate Cloud Engineer
● RAM Disk
○ RAM disks share instance memory with your
applications. If your instances do not have
enough memory to contain RAM disks and your
applications, create instances with high-memory
machine types or upgrade your existing instances
to add more memory.
Google Cloud Associate Cloud Engineer
● Review:
○ We have lots of options for disks for our VMs and
many advantages come from the persistent cloud
aspects of the disks.
Google Cloud Associate Cloud Engineer
● Up Next:
○ Let’s explore the options available for compute on
an instance.
Google Cloud Associate Cloud Engineer
Compute Options
Google Cloud Associate Cloud Engineer
● Machine Families
○ A curated set of processor and hardware
configurations optimized for specific workloads.
When you create a VM instance, you choose a
predefined or custom machine type from your
preferred machine family.
Google Cloud Associate Cloud Engineer
● Series
○ Machine families are further classified by series
and generation. For example, the N1 series within
the general-purpose machine family is the older
version of the N2 series. Generally, generations of
a machine series use a higher number to describe
the newer generation.
Google Cloud Associate Cloud Engineer
● Machine Type
○ Every machine series has predefined machine
types that provide a set of resources for your VM.
If a predefined machine type does not meet your
needs, you can also create a custom machine type.
Google Cloud Associate Cloud Engineer
● Review:
○ We learned about the compute options available
when creating a VM instance.
Google Cloud Associate Cloud Engineer
● Up Next:
○ We’ll create a new VM instance and explore the
topics we discussed on the Google Cloud Console.
Google Cloud Associate Cloud Engineer
VM Lifecycle
Google Cloud Associate Cloud Engineer
● Linux OS:
○ SSH from GCP Console or Cloudshell
○ Can also generate key pairs
○ Information:
■ cloud.google.com/compute/docs/
instances/connecting-to-instance
Google Cloud Associate Cloud Engineer
● Windows OS:
○ RDP (Remote Desktop Protocol)
○ Powershell Terminal and setting Windows
Password
○ Information:
■ cloud.google.com/compute/docs/
instances/connecting-to-windows
Google Cloud Associate Cloud Engineer
Provisioning
vCPU + Memory
Root Disk
Persistent Disk
Added Disks
Google Cloud Associate Cloud Engineer
Provisioning Staging
Root Disk
System Image
Persistent Disk
Snapshot of
Persistent Disk
Root Disk Access with
System Image
Persistent Disk SSH/RDP
Export System
Image
Shutdown
vCPU + Memory IP Addresses Startup Script
Script
Shutdown Availability
vCPU + Memory IP Addresses Startup Script
Script Policy
Delete
Shutdown Availability
vCPU + Memory IP Addresses Startup Script
Script Policy
Delete
Shutdown Availability
vCPU + Memory IP Addresses Startup Script
Script Policy
Delete
Shutdown Availability
vCPU + Memory IP Addresses Startup Script
Script Policy
Delete
● Review:
○ We learned about the typical VM lifecycle
including provisioning, staging, running, stopping,
and terminating an instance.
Google Cloud Associate Cloud Engineer
● Up Next:
○ We’ll explore considerations on compute pricing.
Google Cloud Associate Cloud Engineer
Compute Pricing
Google Cloud Associate Cloud Engineer
● Discount Types:
○ Sustained Use
○ Committed Use
○ Preemptible VM Instances
● Discount types can not be combined.
Google Cloud Associate Cloud Engineer
● Preemptible Instances
○ Preemptible VM instances are available at much
lower price—a 60-91% discount—compared to the
price of standard VMs. However, Compute Engine
might stop (preempt) these instances if it needs to
reclaim the compute capacity for allocation to
other VMs.
Google Cloud Associate Cloud Engineer
● Preemptible Instances
○ Preemptible instances use excess Compute Engine
capacity, so their availability varies with usage.
○ If your apps are fault-tolerant and can withstand
possible instance preemptions this can reduce your
Compute Engine costs significantly.
Google Cloud Associate Cloud Engineer
● Preemptible Instances
○ No charge if terminated in first minute
○ 24 hours maximum
○ Only 30 second termination warning
■ Not guaranteed to warn
○ No live migrate
○ No auto restart
Google Cloud Associate Cloud Engineer
● Preemptible Instances
○ Preemptible instances information and pricing:
■ cloud.google.com/compute/docs/
instances/preemptible
Google Cloud Associate Cloud Engineer
● Review:
○ We covered the pricing mechanics of compute
engine and discussed discounts.
Google Cloud Associate Cloud Engineer
● Up Next:
○ We’ll discuss some more specialized compute
options.
Google Cloud Associate Cloud Engineer
Special Compute
Options
Google Cloud Associate Cloud Engineer
VM VM VM VM VM VM
Hypervisor Hypervisor
Hardware Hardware
Google Cloud Associate Cloud Engineer
● Shielded VMs:
○ Shielded VMs are virtual machines (VMs) on
Google Cloud hardened by a set of security
controls that help defend against rootkits and
bootkits.
Google Cloud Associate Cloud Engineer
● Shielded VMs:
○ Using Shielded VMs helps protect enterprise
workloads from threats like remote attacks,
privilege escalation, and malicious insiders.
Google Cloud Associate Cloud Engineer
● Shielded VMs:
○ Shielded VMs leverage advanced platform security
capabilities such as secure and measured boot, a
virtual trusted platform module (vTPM), UEFI
firmware, and integrity monitoring.
Google Cloud Associate Cloud Engineer
● Shielded VMs:
○ In summary, Shielded VM offers verifiable
integrity of your compute engine instances using:
■ Secure Boot
■ Virtual Trusted Platform Module
■ Integrity Monitoring
Google Cloud Associate Cloud Engineer
● Shielded VMs:
○ More information at:
■ cloud.google.com/compute/
shielded-vm/docs/shielded-vm
Google Cloud Associate Cloud Engineer
● Review:
○ We learned about special VM options including
Sole-Tenant Nodes and Shielded VMs.
Google Cloud Associate Cloud Engineer
● Up Next:
○ We’ll explore some common actions performed
with VMs
Google Cloud Associate Cloud Engineer
VM Actions
Google Cloud Associate Cloud Engineer
● Instance Metadata:
○ Every virtual machine (VM) instance stores its
metadata on a metadata server. Your VM
automatically has access to the metadata server
API without any additional authorization.
Metadata is stored as key:value pairs.
Google Cloud Associate Cloud Engineer
● Instance Metadata:
○ There is a default set of metadata keys that are
available for VMs running on Compute Engine.
○ To query metadata:
■ cloud.google.com/compute/docs/
metadata/querying-metadata
Google Cloud Associate Cloud Engineer
● Instance Metadata:
○ For example, a VM’s external IP Address is part of
its metadata.
○ You can write a script that uses that piece of
metadata to set up a separate database.
○ Default key:value pairs are the same across all
VMs, making scripts robust.
Google Cloud Associate Cloud Engineer
● Moving a VM Region
○ Snapshot persistent disks from source.
○ Create new persistent disks in new region (restored from
the snapshots).
○ Create new VM in new region.
○ Attach new persistent disks and assign static IP Address.
○ Update references to VM and delete original snapshot,
disk, and VM.
Google Cloud Associate Cloud Engineer
● Creating a Snapshot
○ Backup data that is critical to cloud storage.
○ Transfer data between zones.
○ Transfer data from one disk type to another disk
type (e.g. PD HDD to PD SSD).
Google Cloud Associate Cloud Engineer
● Creating a Snapshot
○ Not available for Local SSD.
○ Creates incremental backups to Cloud Storage.
○ Snapshots can be restored to new persistent disks.
■ VM Metadata and tags are not saved.
Google Cloud Associate Cloud Engineer
● Review:
○ We covered some common tasks performed with
VMs.
Google Cloud Associate Cloud Engineer
● Up Next:
○ We’ll go through a comprehensive demo that
combines many of the ideas discussed so far!