Week 2 GCP Lec Notes
Week 2 GCP Lec Notes
Jimmy Iran
SMB Growth Program Manager
Google Cloud
Lecture-11
Billing in GCP
In the next topic, you will learn how billing works in GCP. Billing, it is no fun but a fact of life.
Let us learn more about it. Billing in GCP is set up at the GCP project level. When you define a
GCP project you link a billing account to it. This billing account is where you will configure all
your billing information including your payment option. You can link your billing account to 0
or more projects. Projects that you do not link to any billing account can only use free GCP
services.
Your billing account can be charged automatically and invoiced every month or at every
threshold limit. You can separate project billings by sending up billing sub accounts. Some GCP
customers who resell GCP services use sub accounts for each of their own clients.
36
(Refer Slide Time: 00:59)
You are probably thinking how can I make sure I do not accidentally run up a big GCP bill. GCP
provides 4 tools to help. Budgets and alerts, Billing export, Reports and Quotas. I will discuss
each of these in more detail next.
37
You can define budgets at the billing account level or at the project level. To be notified when
costs approach your budget limit, you can create an alert. For example, with a budget limit of
$20 and an alert set at 90%. You receiving notification alert when your expenses reach $18. You
can also set up a web hook to be called in response to an alert. This Webhook can control
automation based on billing alerts. For example, you could trigger a script to shutdown resources
when a billing alert occurs.
Billing export allows you to store detailed billing information in places where it is easy to
retrieve for external analysis, such as a BigQuery data set or Cloud Storage bucket.
38
(Refer Slide Time: 02:06)
And reports is a visual tool and the console that allows you to monitor expenditure based on a
project or services.
GCP also implements Quotas which limit unforeseen extra billing charges. Quotas are designed
to prevent the over consumption of resources because of an error or a malicious attack. Quotas
39
apply at the level of the GCP project. There are two types of quotas- Rate quotas and Allocation
quotas. Rate quotas reset after a specific time. For example, by default the Google Kubernetes
Engine service implements a quota of 1,000 calls to its API from each GCP project every 100
seconds.
Allocation quotas governed a number of resources you can have in your projects. For example,
depending on your region the number of GPUs permitted varies by type and region. You can
change quotas by requesting an increase from Google Cloud support. You can also use the
console to request a quota change. GCP quotas also protect the community of GCP users by
reducing the risk of unforeseen spikes in usage.
40
Google Cloud Computing Foundation Course
Jimmy Iran
SMB Growth Program Manager
Google Cloud
Lecture-12
Install and Configure Cloud SDK
The cloud SDK enables a user to run GCP command-line tools from a local desktop. Installing
and configuring the cloud SDK is the next topic.
The cloud SDK is a set of command-line tools that you can download and install on to a
computer of your choice and used to manage resources and applications hosted on GCP. The
‘gcloud’ CLI manages authentication, local configuration, developer workflow and interactions
with the cloud platform APIs. ‘gsutil’ provides command-line access to manage cloud storage
buckets and objects. ‘bq’ allows you to run queries and manipulate datasets tables and entities in
BigQuery through the command-line.
41
(Refer Slide Time: 00:49)
To install the cloud SDK to your desktop, go to cloud.google.com/sdk. Select the operating
system for your desktop and this will download the SDK for your operating system on your
desktop. Then follow the instructions specific to your operating system.
42
After the installation is complete, you will need to configure cloud SDK for your GCP
environment. Run the ‘gcloud init’ command, you will be prompted for information including
your login credentials, default project, and default region and zone.
43
Google Cloud Computing Foundation Course
Jimmy Iran
SMB Growth Program Manager
Google Cloud
Lecture-13
Use Cloud Shell
Cloud Shell allows a user to run the Google command-line without installing cloud SDK on a
desktop. In this topic, you will learn how to utilize Cloud Shell.
But what if it is not convenient to install the cloud SDK on the machine you are working with.
Cloud Shell provides command-line access to your cloud resources directly from within your
browser. Using Cloud Shell, you can manage your projects and resources easily without having
to install the cloud SDK or other tools locally. The cloud SDK command-line tools and other
utilities are always available up-to-date and fully authenticated.
So, how does Cloud Shell do that? It’s built using a Docker container running on a Compute
Engine virtual machine instance that you aren’t built for. Each GCP user has one. Your Cloud
Shell virtual machine is ephemeral, which means that it will be stopped whenever you stop using
44
it interactively and it will be restarted when you re-enter Cloud Shell. So, you wouldn’t want to
run a production web server in your Cloud Shell for example.
You also get 5 gigabytes of persistent disk storage that reattached for you every time a new
Cloud Shell session is started. It also provides web preview functionality and built-in
authorization for access to GCP console projects and resources. You can also use Cloud Shell to
perform other management tasks related to your projects and resources using either the g-cloud
command or other available tools.
To start Cloud Shell click on the activate cloud shell icon located at the upper right hand side of
the screen.
45
(Refer Slide Time: 01:49)
The Cloud Shell terminal will appear on the lower portion of the window. Options including
launching the Cloud Shell code editor and opening Cloud Shell in the new page can be
performed using the toolbar on the upper right corner of Cloud Shell.
46
The Cloud Shell code editor is a tool for editing files inside your Cloud Shell environment in real
time within the web browser. This tool is extremely convenient when working with code first
applications, or container-based workloads because you can edit files easily without the need to
download and upload changes. You can also use text editors from the Cloud Shell command
prompt.
47
Google Cloud Computing Foundation Course
Jimmy Iran
SMB Growth Program Manager
Google Cloud
Lecture-14
GCP APIs
Everything you do in GCP is done with APIs. This topic introduces APIs and discusses how they
are used. Let’s be precise about what an application programming interface or APIs. A software
service implementation can be complex and changeable. If other software services had to be
explicitly coded at that level of detail in order to use that surface, the result would be brittle and
error-prone. So, instead application developers structure the software they write so that presents
a clean, well-defined interface that stacks away needless detail.
And then they document that interface that's an application programming interface. The
underlying implementation can change as long as the interface doesn’t and other pieces of
software that use the API don’t have to know or care.
48
(Refer Slide Time: 00:59)
The services that makeup GCP offer APIs, so that code you write can control them. These APIs
can be enabled through the GCP console or what is called RESTful. In other words, they follow
the representations state transfer paradigm. In a broad sense, that means that your code can use
Google services in much the same way that web browsers talk to web servers. The APIs identify
resources in GCP with URLs. Your code can pass information to the APIs using JSON, which is
a very popular way of passing textual information over the web. And there is an open system
OAuth 2 for user login and access control.
GCP APIs also assist in helping you to control yours spend with most including daily quotas and
limits, where needed quotas and rates can be raised by request.
49
(Refer Slide Time: 02:08)
In addition to the Cloud SDK, you will also use client libraries than able you to easily create and
man resources. GCP client libraries expose APIs for two main purposes. App APIs provide
access to services and they are optimized for a supported language, such as NodeJS and Python.
Admin APIs are for functionality for resource management. For example, you can use admin
APIs if you want to build your automated tools.
The different application managed service options will be discussed in more detail later in the
course.
50
(Refer Slide Time: 02:51)
The GCP Console includes a tool called the APIs Explorer that helps you learn about the APIs
interactively. Let you see what APIs are available and in what versions. These APIs expect
parameters and documentation on them is built-in. You can try to APIs interactively, even with
user authentication. Suppose, you have explored an API and you are ready to build an
application that uses it. Do you have to start coding from scratch?
No. Google provides client libraries to take a lot of the drudgery out of the task of calling GCP
from your code.
51
(Refer Slide Time: 03:29)
In this example, the compute.instances.list method from the compute engine API will be tested.
Items listed in red are required inputs. When the method is run you will have to log in using
OAuth 2.0. Since REST APIs are HTTP based if the method runs correctly, you will receive a
200 message and the appropriate data will be displayed. At the project or the zone was entered
incorrectly you will get a 400 error and no data will be displayed.
52