[No Audio]
Open your favorite web browser and go to this link,
console.cloud.google.com. This is the link for
Google Cloud Platform Dashboard, or GCP Dashboard.
But before we can go there, we need to sign in to
our Google account, enter your ID and password,
and hit next. We get a pop-up, which asks us to
confirm about the terms and services of GCP and
also provide Google our residential detail.
I'm putting India, you can put your own country,
and then we have a choice whether we want any feature
updates or survey emails from Google or not.
Well, since I don't want to receive them, I will click No.
[No Audio]
Click on AGREE AND CONTINUE and the prompt
will be gone. What you see in front of your screen
is the Getting Started view of GCP Dashboard.
We have a bunch of most used products like Compute
Engine, which we will be using to create virtual machines,
Cloud Storage, which is Google's
affordable block storage, and Cloud SQL, which
is managed MySQL or PostgreSQL from Google.
But before we can use any of these, we need to set
up something called Billing, which means we need
to initiate our free trial of Google Cloud account
by doing which, we will receive a $300 credit,
which can be spent within a year. Click on try for free.
It seems like it is a two-step payment setup
process. Google is explicitly stating that we will
get $300 credit for free for starting this trial
account and even once the credits are finished,
we won't be charged unless we agreed to be billed.
Step one is pretty much similar to what we have
done previously to the prompt which appeared.
We need to agree to the terms and services of Google,
and we need to tell them whether we want email
setup or not. And click on AGREE AND CONTINUE.
Step two involves personal information, like
Account type, which can be either Business or
Individual, Tax information, which can be
Registered or Unregistered Individual, Billing
Name, Billing Address, etc. Once you have filled
in all of these details, when you scroll down, we
get to the payment methods. Currently, the
available option is Monthly automatic payments.
And to enable them, we need to provide credit or
debit card details. If you live in a country like
India, where electronic transactions are protected
by one time passwords or 3D pins, your debit card
will not be accepted and you will have to use a
credit card. The bottom line is whichever card you
use, should have feature of auto payments. Once you
enter your details, hit on start my Free Trial button.
And the next screen says that Google is
creating a project for us, and this may take a few moments.
It seems like our free trial is set up.
Now we have $300 credit on our Google Cloud
Platform billing account, and we can get started
by using GCP services. So what do we want to try first?
Well, I want to try Computing and
applications, so let's click on that.
[No Audio]
These services or these provisions from Google fall
under the category of computing services. Now if
you take a look at the left-hand side pane, we
have multiple options here. Currently, we are on
Getting Started tab, but the other tabs are
Billing, Marketplace, APIs & Services, Support
which would provide consumer and business level
support, IAM & admin, which is useful for
setting up permissions and roles, Security, etc.
Let's click on Billing.
This is the overview page of our billing account.
And it says that we held $300 or 22,183 INR
or Indian Rupees remaining in our credit. Also, the
tenure remaining for credit is 365 days or a year
because we have just started using GCP. If you see
below it, we have a project link to this billing
account, which is my first project. In case of
Google Cloud Platform resources, services, provisions, etc,
are managed under projects, which means that
one GCP account can have multiple projects for
multiple purposes. We have a default created
project, which is called My First Project. GCP has
provided it to us and if you remember, we had
previously seen a screen, which said creating your
first project. Well, it was this project.
We will be using this project throughout this course.
Go to the upper pane of our dashboard, and click on
the drop down menu of project, which appears right
after the Google Cloud Platform. Now let's click
on Home button and let's select my first project
as our project. Once we have selected the project,
the view of our dashboard changes and instead of
having a Getting Started view, we are having our
project specific view, where the information is
divided into multiple cards. The first card is
Project info, which gives information about the
Project name, Project ID, and Project number,
which are unique across the globe. Then, we have the
resources card. Right now, we don't have any
resources provision, so it says this project has no resources.
Then we have APIs card. The more we
use GCP APIs, the more fluctuations we will see
in the graph of this card. Currently, we haven't
used much of the APIs, so the graph is pretty
much plain apart from one spike, which might
have generated when we activated our free trial.
Then we have Google Cloud Platform services
status, and it says All services are normal.
Next up is error card, we have no signs of any errors,
which makes sense because we haven't used any
resources in the first place. Then we have some
miscellaneous cards, like News, Documentation,
Getting Started, etc. Let's click on the
navigation menu icon of GCP dashboard, which is
also called the hamburger icon, or three
horizontal lines, which are on the top left corner
of our dashboard view. Go to Compute Engine
section and click on VM instances. Since we don't
have any VM instances created whatsoever, we are
getting this response, we have three options.
First, to take a quick start tour, second to import
some VM or third to create a VM or virtual machine
by ourselves. Well, let's create a virtual machine.
Now we are guided to virtual machine
creation page where Google has filled in default
data for a standard virtual machine. But we will
modify it a bit. Let's change our instance name
to Master, then we have two location related
choices which include region and zone.
Region indicates the overall place, whereas zone indicates
a particular data center within that region.
Let's change our region to asia-south1,
which redirects to Mumbai. And accordingly, we are
choosing asia-south1-c, you can choose your
closest region and zones accordingly.
In this course, the choice of region and zone will not
matter that much. But if you are making some
performance intensive applications, where you might
require a certain type of resources, like GPU,
you may have to choose regions and zones which provide
those resources. Having said that, next up,
we have machine type. The default value for those is
1 vCPU, which means 1 virtual CPU
and 3.75 GB of memory, it means that our virtual
machine will have 1 virtual core of CPU assigned
to it, along with 3.75 GB of RAM.
Let's increase both of these provisions to 2 vCPUs,
and 7.5 GB of memory. Next up, we have an optional
choice to make, whether we want to deploy a
container image to this VM instance or not.
Well, we don't want to deploy a container image,
because we'll be doing all of those things by ourselves.
Next up is Boot disk, which means which operating
system will be used on this VM. The default is
Debian Linux 9, but we will change it to Ubuntu 16.04.
We can also choose between SSD persistent
disk or Standard persistent disk and both of their
limits are 65,536 gigabytes. We will stick to
Standard persistent disk but increase the limits
to 20 GB, let's hit Select. We will keep our
service account as Compute Engine default service
account, and we will allow full access to all
Cloud APIs. Although we won't be using most of
the APIs, having access just avoids potential
errors. Finally, we have Firewall settings where
we are going to allow all HTTP and HTTPS traffic.
Let's hit Create button. We are redirected to VM
instances page, and our master instance has been
created. If we click on it, we can see the
information that we had provided earlier.
On top of that, we get another bunch of information such
as the CPU platform, which is Intel Skylake,
Creation time, Network Interface details, Firewall
details, Boot disk preferences, etc.
Let's go back to VM Instances page. If we click on the
checkbox, right beside the master instance, we see
a few buttons lit up, they respectively allow us
to stop, restart, or delete the VM instance.
But we won't be doing any of that, because we want to
keep this instance and want to work on it.
In fact, we will create 2 more of such VM instances,
and we will name them node-1 and node-2.
It is recommended that you create all of these instances
in the same region. There we are, our two other
instances are created. You might be wondering, the
instances are created, means VMs are ready. But how
do we use them? Well, the simple most option to
connect to it would be to SSH into it, and the
moment I said SSH, I know your site is stuck on
the SSH button. But before we click on that, take
a look at the internal and external IP of all of
our VMs. Let's connect it, we have multiple
options, but we will choose the first one which is
open in a different browser window. There we are,
we are connecting to the master instance of master
VM instance of our GCP Compute Engine.
The connection seems successful. Let's clear the screen out.
Now we want to bootstrap a Kubernetes
cluster on these instances. So let's start by
getting root privileges. Run the command sudo su.
Let's run a standard update using apt-get update.
Once the update is finished, let's install Docker
using apt-get install docker.io and provide the
flag -y for default yes.
[No Audio]
Let's check out if our Docker is installed properly.
Run docker version and it says that we
are running Docker 17.03 Community Edition,
which is perfectly fine because that's what we wanted to run.
If you're wondering why are we running
Docker? Well, Kubernetes is just an orchestrator.
It still needs a containerization platform, so we
are installing Docker.
Oops, looks like I closed
the window. Well, let's open it again. Now let's
install some basic dependencies of Kubernetes,
like HTTPS and curl, the installation seems successful.
Now let's get the GPG for GNU
Privacy Guard key for Kubernetes and add it to the system.
We get the response OK, which means that
the key was added successfully. We are adding the
line the deb which stands for Debian followed by
the link which is http://apt.kubernetes.io/kubernetes-xenial main
at the end of our sources.list file. We are doing
this so that our apt-packagemanager can access
Kubernetes libraries whenever it is performing
updates. Let's verify if the step was successful.
Run apt-get update again, and as you can see,
our last Get: 7 entry includes update received
from Kubernetes URL. Now let's install all of the
components of Kubernetes which include kubelet,
kubeadm and kubectl. Run apt-get install
kubelet kubeadm kubectl accompanied by the flag -y.
Looks like the installation is complete.
Let's exit our SSH and log in again. Run sysctl
command and set our default net.bridge iptables=1.
This is a prerequisite for installing
the pod network which we will be using while
setting up the Kubernetes cluster. Now let's
initialize our Kubernetes cluster using kubeadm init command.
Seems like the cluster initialization is in progress.
And once the preflight checks are complete,
we are getting a lot of certificates generated.
Once the initialization is complete, we have provided a few
suggestions. First of all, we have a confirmation
that our Kubernetes master has been initialized
successfully. Next up, we have a bunch of
commands, which should be used if we want to use
this cluster as regular user and not just root user.
I recommend, you copy all of these three
commands at a safe place, because we will be using
them later on. Next is a suggested command to
deploy a pod network on the cluster. But we don't
need to copy that. And finally, we have a kubeadm join command
followed by the token, which is
generated by our master and 64 digit certificate,
which we must copy and save at some place.
Because this command is extremely crucial, and will be
used by all other nodes to join our master.
Once you have copied all of this, let's clear out the terminal.
Before we proceed any further, make sure
you don't leave any unnecessary white spaces
when you copy the command. Now let's run kubectl apply
command followed by the URL of our pod network configuration.
We are using weave net, so the URL
starts with cloud.weave.works. But you can
use any pod network you like such as Flannel,
Calico, etc, and the details for other pod
networks can be found at Kubernetes documentation.
It seems like our pod network is set up.
Let's check if our cluster is working. Run kubectl get pods
followed by a flag, --all-namespaces.
You don't need to dig too deep into
this command, because we will be going through the
whole Kubernetes command line step by step.
All you have to notice are the familiar names such as
etcd, kube-apiserver, kube-controllermanager,
kube-proxy, kube-scheduler, etc. All of these are
components of Kubernetes architecture, which we
have studied in theory. And now they are deployed
on your Google Cloud VM instance. Of course, these
were the components of a Kubernetes master.
For node instances, we will have different components.
Now, let's grant regular user access to our master.
Run the three commands one by one, which we had
copied earlier. And to see if our Kubernetes is
working on regular user or not, let's run the same
kubectl get pods command again. And it seems like
all of the pods are up and running and Kubernetes
master is accessible from regular user as well.
Now let's get back to our GCP VMs page and SSH to node-1.
Let's get the root user access again.
Now run kubeadm join command. If you remember,
we had run kubeadm init from master and we had
received a token from there. Now we are using kubeadm join
from node instances to join the master
as the members of cluster. The tokens which we are
providing are the same that we had received when
the master was initialized, press Enter.
There we go, once the joining process is complete,
we get a suggestion that we should run kubectl get nodes
on master to see if the node has joined the cluster.
Well, we'll do it, but after making node-2 join the cluster.
Back to GCP VMs, let's SSH to node-2.
Nothing too complicated, exactly the
same steps which we had performed on node-1.
Get the root user access and run the kubeadm join
command with the same tokens.
Once that is done,
let's follow their suggestion and head back to
master. We have already set up a non-root user
kubectl access on master, so we don't need to run
sudo su again, just simply run kubectl get nodes.
And there we go, we have all the three nodes listed,
but if you notice, node-1 is not ready yet.
Nothing too much to worry about. Let's give
it some time and run the command again.
Bingo, all of the nodes have joined the cluster successfully
and are ready to work on. Now that our Kubernetes
cluster is properly set up, we are ready to explore
different aspects of Kubernetes like Workloads
kubectl, command line, etc. See you in the next
See you in the next lecture.