This content provides a step-by-step guide on how to set up a Google Cloud Global External Application Load Balancer, detailing the necessary components and configuration steps from front-end to back-end, including the addition of multiple virtual machines to an instance group.
Mind Map
Clicca per espandere
Clicca per esplorare la mappa mentale interattiva completa
Let's continue further and in this
chapter we are going to talk about the
Google cloud load balancer. So this is
the target architecture diagram which
you can see which we will be
implementing into our demo. But don't
worry we are going to break everything
down and we are going to start from the
scratch so that we understand how the
load balancer work. But let me give you
a little walk over on what are the
different component which we need to set
up a global external load balancer. So
here you can see on the left hand side
this is uh any user who is sitting
anywhere in the world that can access
the external uh load balancer with the
IP address. Remember we are only
performing the load balancer setup. We
are not performing any DNS a record or
URL mapping to this particular load balancer.
balancer.
After that you need to configure the
front end. Don't worry I'm going to
explain what the front end is and what
are the component which we need to
include inside it. But in a brief it
will require a protocol and a port and
protocol would be HTTP and port can be
anything on your application. After the
front end is configured then it comes to
the backend services or the back end
which we call it. So in the back end
which we need to create a backend
service and that backend service will
consist of health check health check of
your virtual machine which is sitting
over here which you can see. Secondly,
the protocol again what the protocol or
which kind of protocol your application
is supporting which is uh running inside
your virtual machine. So it can be HTTP
mostly it is HTTPS or HTTP.
Second the port and port again it
depends upon what kind of application
you're running and which port it is
running. It can be 80, it can be 9,000
any port which you want to configure for
your application. After that there is a
instance group. So these four component
will comprise to create a backend
service. Okay. So I have explained
health check which will keep on checking
the health then protocol uh which
protocol it is supported then port and
the final one is the instance group. The
instance group is bit special and it is
it is a logical group. So we need to
create an instance group and in that
instance group we will be clubbing or
grouping the virtual machine. So here
you can see this is a instance group
which we need to configure and in this
instance group we can add and remove the
virtual machine and add and remove which
means like if you are adding more and
more virtual machine then this
particular external load balancer will
be able to route the traffic on those
virtual machine. So right now here you
can see there are three virtual
machines. So external load balancer will
try to route the traffic or distribute
the traffic on these three virtual
machine. You can have a one virtual
machine also into the instance group but
that doesn't make any sense because one
virtual machine then why do you need a
load balancer but that's not a point.
The thing is uh in an instance group you
can have from one to more than one
virtual machine. So first we are going
to perform this demo with one virtual
machine and then later on we will be
adding the more virtual machine into the
same instance group. Let's start with
the demo and if you are directly coming
to the load balancer chapter then in our
previous chapter we have configured the
VPC uh our subnet and in that subnet we
have also configured the virtual machine
firewall. So that kind of a setup we
have already done. So now we will start
with the load balancer setup. So we'll
continue from here and if you want to
know like how this things works like a
VPC subnet and virtual machine then
please refer to the previous chapter
where I have explained the VPC subnet
and how to perform these kind of a setup
onto the Google cloud. All right so
let's get back to the topic of a load
balancer. So here you can see this is
our uh current setup and here we need to
add an external load balancer. So if you
move further then here we will be
creating our first external load
balancer and here I will be working only
onto my public subnet. Since this
virtual machine is public but still I
would like to set it up through the
external load balancer so that I can
have a multiple virtual machine running
inside my subnet and my external load
balancer should be able to route the
traffic onto those virtual machines. Now
let's jump back to our Google cloud
console and see where our where we can
create our external load balancer and
where is our virtual machine currently
present. So I will switch to my Google
cloud console and here you can see this
is the search box where you need to type
uh load balancer first of all. So if you
click on load balancer
then here this is the section where we
will be creating our first load
balancer. Okay. Next thing we need to
also verify where our virtual machine
is. So here again in the search box you
can type VM instances
and here you can see there are couple of
virtual machine. So here we are going to
target the public virtual machine. All
right. So first we are going to start
with the single virtual machine and then
later on we will be adding more virtual
machine towards the end of this
particular demo. Okay. Now get back to
our this particular tab where we need to
create our first external load balancer.
So here just click on create load
So here you will find a couple of
options. So one is our application load
balancer and network load balancer. So
we are interested into our application
load balancer for our HTTP traffic. So
choose this option. Uh let's click on
next over here.
Then uh it is going to ask do you need a
public or do you need a internal? So we
are going to go with the public so that
I can access that public uh load
balancer from anywhere. So this is the
option I'm going to choose.
Click next over here.
Then here it is going to ask like a
global or a single region deployment. So
I'm going to go with this global uh
workload so that I can access uh or I
can deploy my virtual machine into
multiple regions and I can configure my
uh global load balancer.
And here this diagram also signifies the
same thing. So here you can see I can
spin up my virtual machine into multiple
regions. And but if I go with this
particular option on the right hand side
which you can see which is regional load
balancer then it will be spinning up a
virtual machine on a single region. So
that's the key difference between these
global and a single region deployment.
Let's go further. Click on next over
here and here you will find uh load
balancer generation. So here there are a
couple of more option like a global
external application load balancer or
you're going to go with the classic
application load balancer. So I'm going
to go with the uh global external
application load balancer. And here it
is uh few more advantage which you are
going to get over here is the advanced
traffic management. So that gives you a
little bit more feature on how you're
going to manage your traffic which is
coming through your external load
balancer to your virtual machine.
Okay. Then click on next over here. And
after that uh it will uh point you to
the screen where you can start putting
the values for your external load
balancer. So click on configure over
here. And here you can see uh the same
thing which I was explaining in the
beginning of this particular chapter is
the front- end configuration, backend
configuration, routing rules and then
you need to review and finalize. So we
need to set up first of all with the
front end. Then we are going to jump to
the back end and then we are going to
set up some routing rule. Routing rules
are very simple in this particular demo.
And then finally review and create that
particular load balancer. A short pause
over here. If you're really liking these
kind of a content on my YouTube channel,
then I'm soon going to come up with my
Google cloud course on UDI. I already
published a few courses on AWS and Azure
on my UDI. So please keep an eye and I
will be making a notification on my
community when I'm ready with my Google
cloud course and what you are going to
get with that particular course is quite
a lot of thing which I'm not going to
cover on my public YouTube channel. So
here you can see this is a terapform
repository which I have already created
for my ODMI courses where I will be
composing the same demo uh with the
terraform because in industry we work
with the terapform not with the UI. So
yeah that's that's uh the depth I will
be uh going through in my ODMI courses
and also I will be covering various
scenarios which uh which is really
useful for industry when you are working
with the cloud uh such a cloud services.
So keep an eye uh on my announcement
when I I'm ready with my Google cloud
course. Uh let's get back to the topic.
Now we need to create our load balancer
name and also most importantly we need
to create a front- end configuration. So
let me show you the uh diagram which
will help you to understand. So right
now we are setting up the load balancer.
This virtual machine is already existing
onto my subnet. So the next thing which
we need to set up over here is the front
end configuration which you can see. So
here we are going to specify the
protocol port and we are going to assign
the name to our external load balancer.
So let's get back to our screen over
here and I'm going to copy the name of
my load balancer from my uh notepad so
that we can continue following the
naming convention. So here I'm going to
put the name of the load balancer. So
which is this one uh like a CL external
LB sandbox Europe not. So I'm going with
the more meaningful name over here. Now
the front end configuration. So here you
need to enter the name. So here probably
we can check put a name something like
LB
and after that you can put Europe not to
or whatever you want to put it uh over
there just to identify that it is
belonging to which region. So after that
or maybe we can just remove that uh
region as well because it's external
load balancer so we don't need to put a
name over here. So I'll go with the
normal name like external LB sandbox.
And here also I will be removing this part.
part.
Okay. So after that you need to choose a
protocol. So it is going to be HTTP. And
after that we need to specify the
application where it will be running. So
it will be running on a port 80. It
depends like if your application is
running on some other port then please
use that particular port. And remember
we are not configuring HTTPS yet. So
that's why I'm using the protocol HTTP
over here. Okay. After that uh click uh
that the front end configuration is
completed. Now let's move to the second
part which is the backend configuration.
So on the left hand side you will find
the option to click on backend
configuration. Now click on the backend
configuration over here and here you can
see uh you need to create a backend
service and the configuration. So in
this backend configuration you will find
a drop-down over here which will include
the backend services. So we need to work
on the backend service and that backend
service will help us to uh create the
group uh the instance group the health
check to point to our virtual machine.
Okay. Uh I'll show you the presentation
once again so that you can understand.
So now we have done this part which is
this one. Now the next thing which we
need to create is the backend
configuration. So here if you go over
here then we are creating a backend
service and in that backend service we
will be setting up the health check
protocol port instance group. All right
let's continue over there onto the
screen. So here in the drop-down you
will find a service like create a
backend service. So we need to choose
this particular service over here. Click
on backend service
and here we need to put the name. So
again I'm going to copy some meaningful
name from my uh notepad. So here this is
the name. So CL backend service sandbox
instance group. So here we are going to
put our request or our load balancer is
going to redirect our request to the
instance group. Instance group is a
group of virtual machines. So here the
back end type will be our instance
group. So here you can see there are
various option but here we are keeping
the things simple instead of using
complex like a GKE and all those cluster
we are keeping it to the virtual machine
which is our instance group select that
one protocol again the protocol is going
to be the same HTTP and the port we need
to put over here is 80 because that's
where our application would be running
so here I'm going to put a port
which is 80 oh sorry here it is not
going to be the port it is going to be
the same HTTP. So let me undo this one.
So it is going to be the named and port.
So which is going to be our HTTP
timeout. We are going to keep it
default. Don't change it 30 second. If
you want to change it that's fine but
let's keep it default. The next
important thing over here is the health
check. So we need to create our health
check also. So if I show you onto my
presentation then I'm talking about this
particular health check. So this health
check will keep on continuously checking
the health of our virtual machine and
the application running inside that
virtual machine. So this backend service
is also comprises of health check which
continuously monitors the health of
virtual machine. So that if a request if
if by any chance if this virtual machine
goes down and there is another virtual
machine running which is healthy then
this load balancer will try redirect the
traffic to this healthy virtual machine
instead of this one. So that's why we
you need a health check and you need to
configure a health check inside your
backend service. Now let's get back and
here in the drop-down you will see there
is no health check. So we need to create
a health check over here and here you
can put a name to the health check. So
let me copy the name from my notepad and
we can put a health check name over here
as well.
So the name I'm going to put is CLVM
health check sandbox. Description uh if
you want to keep it then keep it and uh
otherwise it is optional. The protocol
and the port is going to be TCPN port is
going to be 80. After that, the health
check criteria. Uh if you want to keep
it a little bit low, you can keep it low
as well. Since it's a demo, so I'm
keeping it 2 seconds. It's a bit
aggressive, but you can increase it to
five or 10 seconds as well. After that,
uh I am going to click on create over here.
here.
And here you can see our health check
will be created uh for my load balancer
backend service. Okay. So here you can
see our health check has been created
and associated with my backend service.
Let's move further and the next thing
which we need to create over here is the
instance group. So let me show you over
here into this particular uh diagram
over here. So here we need to create a
instance group and uh in this instance
group uh we will be adding the virtual
machines. All right. So right now health
check is done, protocol is done, port is
done and now we are working on the
instance group. So let's see from where
we can create a instance group. So again
go back uh to our console and here you
can see the previously we were here
health check has been created and if you
scroll it down then you will find a back
ends. In the back ends you will find a
instance group drop-down which is this
one. So let's click on this one and see
what we have. So there is no instance
group which we have created. The list is
completely empty over here. Now what we
need to do, we just need to go to uh the
new tab over here. Uh probably I think I
need to recreate the same setup once
again, but don't worry uh I I'll show
you. So here uh instance uh group click
on this instance groups over here and
here you need to click on instance group
option. So let's click on this instance group.
group.
Here you will find three options like uh
managed instance group, manage instance
group, stateful, stateless and stateful.
Then unmanaged instance group. So I'm
going to go with the unmanaged instance
group for this particular setup. Let's
click on this unmanaged instance group
setup. Here you need to enter the name
of instance group. So let me copy the
instance group name. So let's go with
this name over here. After that
description, it's optional. Secondly,
the location. So in which location you
are working. So if you take a look onto
this particular diagram then we are
working into the Europe North two
region. So I'm going to go with the same
location. So here I'll go and choose the
region which is our Europe North 2 which
is Stockholm region and zone. Uh here if
you are looking for any specific zone
then you can choose otherwise here you
will find all the three options. I'll
I'll explain how it how it works. Now
secondly the network. So if you take a
look onto our diagram then which VPC we
are working. So we are working onto this
particular VPC which is our CLVPC
sandbox and we are going to create this
instance group to mention that hey I I
will be working into this particular VPC
and this particular subnet over here.
Okay. So let's mention that particular
VPC from the drop-down in the network.
So which you can see over here which is
available after that uh subnet. So here
you can see there are two subnets which
is web and the private and if you take a
look onto the subnet then we are working
on the web subnet which is this one.
Okay. Now copy uh not copy but choose
the web subnet over here and here you
need to choose the virtual machine. So
here you can see the virtual machine is
visible which is we which we have
created. So let's select this virtual
machine and click okay. Check the name
of this virtual machine which is sandbox
bastion 01. So if you go to virtual
machine then here you can see sandbox
bastion 01 Europe North 2. All right. So
now we have created an instance group
and here we have selected one virtual
machine into it and after that uh we
just need to click on create
and also there is a one more thing uh to
send the traffic to this particular uh
port incoming traffic load balancer to
create a load balancer instance group.
So here we also mention here we can also
mention the port. So here click on the
port and port which we are going to
mention is like uh let's say TCP and the
port number is going to be 80 because
this is the port where our traffic will
be landing or from where our application
will be serving the request. After that
click on create over here.
And here you can see our unmanaged
instance group has been created. All
right. Now let's get back to our load
balancer setting which we were doing. So
here if you go okay now since uh my
instance group was not ready so the
backend service configuration which I
was creating uh was lost. So again I can
retype those configuration. So again
I'll start but don't worry our some of
the configuration are still saved. So
here let me start with the backend
service once again. So I'll copy the
name over here which is this one which
is instance group. I need to select it.
Protocol HTTP network named port is
going to be HTTP. Health check which we
have already created which is this one.
So it is still there. Instance group.
Let's see if it is popping here. You can
see the instance group is now visible.
All right. So select this instance group
over here.
Use existing port name. Uh instance
group has a named port name. Do you want
to use the TCP for this backend service?
Uh I can choose use existing port. Yeah,
that's fine. After that uh back end
utilization so here you can uh configure
the rate uh custom matrix and utilization.
utilization.
So I'll keep the things default over
here. We don't need to change anything
at this point of a time. After that uh
we are pretty much I think good with the
backend services. Once you verify all of
these details then what you can do is
you can go at the bottom and here we
need to click on create option. But
there are few more things which you can
verify at the bottom. what are those? So
there are a few more details which you
can see over here is like uh cachier
mode. I'm not going to change. I'm going
to go with the recommended setting over
here. After that uh at the bottom you
will also see the cloud armor policies
and all those things. So I'm going to go
with the default one. I'm not going to
change anything. We're going to take a
look onto those later. Uh the more uh
cloud armor how cloud cloud armor works.
After that uh yeah I think we are pretty
much good with the back ends uh
configuration then click on uh create
option over here
click on create
uh let's see make sure all the fields
are correct okay let's see what field we
have missed over here
and let's go one by one all right so
here you can see uh it is complaining
for this policy name because it's going
to assign the default name to it and I
have previously uh like practicing this
particular thing. So this name is
already occupied. So what I can do I can
just uh add a 01 over here so that I
don't get a conflict over here. Okay.
Now after that click on create
and click on okay over here. So now my
front end backend configuration has been
created. Let's take a look onto the
routing rules. So click on routing rules
over here. [snorts] So here we don't
need to change anything because we our
routing is very simple where our
external load balancer is capturing the
request and sending it to our virtual
machines. Okay. After that uh click on
review and finalize. So here you can see
you will verify all of these details. So
which is our front end which is uh run
accepting the request on a board at
routing rules it's all default over
here. Backend service here we have
created a back end. This is our health
check. And this is our security policy
and these are our backends with our uh
instance group. Okay. After that you can
just simply go and click on create over here.
here.
So I'll just go over there and click on
create. And after that uh here you can
see uh this is creating our load
balancer. So it will take a few minutes.
I'll be back once this load balancer is
up and running. All right. So after a
few minutes my load balancer is up and
running. So here you can see the load
balancer has been created and the
backends are green right now. Uh we need
to do few more checks over here. So if
you click on this particular one then
here you will find a more details like
health checks. So here if you go and
take a look onto this one if your uh
load balancer is not working then please
go and check this particular health
status because many of the time your
health checks will be failing and then
you need to take a look on which port
you have configured is your application
running inside your virtual machine or
not. Okay anyway since uh my health
checks are green everything is working.
So here you can see on the top that this
is the public IP address which I got. So
I can copy this public IP address from here
here
and go to the new tab and hit enter. And
here you can see it is pointing me to
the application uh which I'm running
inside my virtual machine. So this is
the IP address of that particular
virtual machine. I'll show you this uh
particular virtual machine. So here on
the VM instances which you can see this
is the IP address which I'm talking
about. So this is how we are able to
redirect the request to this particular
virtual machine. Now you might be
wondering that which application and how
I have configured this particular page.
So here uh onto this particular virtual
machine. So here I have already logged
in into this virt virtual machine over
here and here I am running that
particular uh application which is uh
which is just an Apache web application.
So I will post that particular
instruction like how to install those
Apache this uh like a basic HTML page
which you can do and go and test uh with
your load balancer setup. So this setup
is very simple. Please check the
description section where I will be
uploading these particular script to
install the Apache and this basic HTML
page. Okay. So uh so that's how uh we
are going to configure the load balancer
and right now it is only single virtual
machine which I'm pointing but we can
add few more virtual machine into this
particular instance group. So let's take
a look onto the uh uh structure or the
implementation diagram which we have
been practicing. So here you can see
this is the virtual machine which is a
part of this particular instance group
and now the load balancer is able to
redirect the traffic. The next thing
which I would like to do is also to set
up a one more virtual machine inside
this particular instance group. So first
of all let's spin up a one more virtual
machine and then try to add that
particular virtual machine into this
particular instance group and then we
will see that it is able to redirect the
traffic or not. Let's create the virtual
machine. So click on this virtual
machine option over here.
Here I'm going to put a name. So let's
put uh uh cl uh
uh
bastion not bastion but uh test uh VM uh sandbox.
Okay. And put a name over here like a
01. And here I'm going to choose the
region as a Europe North 2 uh zone. I'm
going to keep it. Let's go with the A.
And uh after that I'm going to choose
the E2 over here. And here I'm going to
choose as uh E2 small.
After that advanced configuration, we
don't need to change anything. OS I'll
keep it Debian. Uh data protection I
don't need to worry about that part
much. Uh networking. Uh so here uh we
need to assign the network tag also. But
uh let's let's first check the network.
So here I'm going to choose the region
uh the VPC as a CL VPC sandbox. The
subnet I'm going to choose is the public subnet.
subnet.
Also let's verify few more things from
our existing virtual machine before we
add it. So let's get back to VM instances.
instances.
Uh click on this one
and here we need to check the network uh
tag. So this is the network tag which we
need to use exactly the same
uh which is over here. Okay. And after
that let's take a look onto the region
if that region information is available
over here.
So here let's take a look.
Yeah you can see it is a region. So
location is Europe North A. Okay. So
let's go further and uh we have assigned
this one. We have assigned this one. All
looks good. After that let's let's go to
the observability. We don't need to
change over here security. Here we need
to attach our access key. So here I'm
going to take a look on add manually
key. Uh let me copy the SSH keys from my laptop.
so here this is the public key which I'm
and let's get back to this one and after
that [clears throat] I'm just going to
click on create
so this is the virtual machine don't
worry if you feel that I was too quick
then Please refer to the previous
chapter where I have shown in very much
detail how to spin up your first virtual
machine. So please take a look. I'll be
back once this virtual machine is up and
running and then we will be adding this
virtual machine into our instance group.
So here you can see my second virtual
machine is up and running and this is
the public IP over here which you can
see. So I'll try to access that
particular virtual machine from here. go
back to my virtual machine
and here uh this is the command here I
will be changing the IP address and hit
enter and here you can see I'm able to
access my virtual machine
right now the next thing is I will be
installing my application I'll show you
how to install that particular
application and you can use the same
script to configure your basic HTML page
so this is the script which I'm going to
use uh so either you can create a shell
script Or either you can just simply
copy these instruction and go to your
virtual machine and do it do the
installation. So here it is going to
update the package manager. After that
and here you can see the Apache is
getting installed. It will take a few
seconds. It's fairly quick when you need
to install it. And uh after that we are
going to configure this uh like a basic
HTML page which you can see over here.
So this is just an simple HTML page
which will be putting like a host name
the IP address the host name and the IP
address so that we can identify on which
server the request is going. Okay so
let's take okay so Apache has been
installed. Now I'll clear the screen.
Now I need to become a root sudo sue and
after that I'm going to copy this
particular one
request uh a command and here just hit
enter. That's done. So here you can see
I have created this index.html page
which will be served and this is the
content host name and the strong uh IP
address. Click on exit from here and
after that we just need to restart the
Apache. So here I'll just copy this one
and here I'm going to restart it. Now it
has been restarted. [snorts]
Here you can see it is up and running
and then we can run the command curl
local host
to see if it is producing the output. So
here you can see it is producing the
output and the IP address has been
changed. Previously it was 1.7 and now
it is 1.8. Okay, so let me show you back
once again. So we have done the setup so
far that we had a one virtual machine
and one virtual machine was configured
to the load balancer. But now we are
spinning up a one more virtual machine
and trying to put that one into over
here. So this part we have done it
spinning up a virtual machine. Uh so here
here
so now we will uh be configuring inside
our this particular uh instance group
which where we already have a this
machine but we need to add this
particular virtual machine also. So
let's get back to our Google cloud
console and here let's take a look onto
the instance group.
Click on the instance group over here.
Click on this particular instance group
and here uh we just need to click on
edit because here we need to add it. So
here you can see this is only one
virtual machine now we need to add
another one. So click on edit over here
and uh here if you take a look then in
this particular dropdown you will find a
option of the second virtual machine
which we have recently added. So here
from the drop-down go over here and
select the second virtual machine.
Select that one. Click okay. And then
click on save this particular one. And
now our second virtual machine is also
added to our instance group. And once
this instance group is updated then load
balancer will automatically start
sending the request to this particular
virtual machine as well. So here you can
see uh now if you take a look onto this
particular page so both of the virtual
machines are added over here. Now let's
take a look onto the health status of
our load balancer and is it pointing to
both the virtual machine or not. So here
again go back to your load balancer and
here onto the load balancer name click
and if you go at the bottom then here
you can see the health status count has
increased from 1 to two because we are
having two virtual machine right now and
both of them are in healthy status. So
let's verify whether our load balancer
is able to request or route the request
or not. So here I'll copy the IP address
and here I think this is already there.
So I'll paste it. So here just refresh
the page. Right now it is pointing to
1.7. Let's refresh it. And now you can
see it is pointing to testvm. Sendbox 01
which is 1.8. And the IP address is
still the I'm using a single IP address
which is 182 which is of my global load
balancer. [snorts] So keep on refreshing
and see if request will keep on uh
routing to both the virtual machine. So
this is how this whole uh load balancer
setup will work. And right now I have
shown you only these two virtual machine
but you can keep on adding three, four
and more virtual machine to your
Clicca su qualsiasi testo o timestamp per andare direttamente a quel momento del video
Condividi:
La maggior parte delle trascrizioni è pronta in meno di 5 secondi
Copia in un clicOltre 125 lingueCerca nel contenutoVai ai timestamp
Incolla l'URL di YouTube
Inserisci il link di qualsiasi video YouTube per ottenere la trascrizione completa
Modulo di estrazione trascrizione
La maggior parte delle trascrizioni è pronta in meno di 5 secondi
Installa la nostra estensione per Chrome
Ottieni le trascrizioni all'istante senza uscire da YouTube. Installa la nostra estensione per Chrome e accedi con un clic alla trascrizione di qualsiasi video direttamente dalla pagina di riproduzione.