AWS ALB (Application Load Balancer) - Step By Step Tutorial (Part -9)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this part nine of this AWS series we are going to take a look onto the AWS application load balancer all right so let's start with our first basic building block for this whole setup so that is going to be the VPC so here you can see this is the VPC which we need to create onto our AWS environment so I'm just going to switch to my AWS console so this is my AWS console type in the search box VPC click on the VPC here click on create VPC click on VPC only because we are only interested in creating VPC enter the name so I'm just going to put test VPC then we need to specify the uh IP ranges so here I'm just going to choose the IP range uh this is a user defined you can change and you can put your own default IP range which you want to have it okay so that I have a specified tency I'm just going to keep it default tag I'm just going to keep it uh test VPC and after that you just click on create VPC and here you can see our VPC has been created which you can verify by clicking over here and here you can see this is the test VPC which we have just created moving ahead the next block which we need to create for this targeted architecture is the internet gateway so this is the internet gateway which we are going to associate with our VPC so again switch back to our console and here onto VPC dashboard uh you will find an option for internet gateway so just click on here here you can see there is no internet gateway has been created click on internet gateway then here you can specify the name so I'm just going to copy from my notepad and past it over here and this is the igw that's abbreviation I'm keeping it and and the key name I'm the tag name I'm just going to keep it name and internet gateway test so click on create internet gateway and here you can see our internet gateway has been created but remember that internet gateway is not associated with the VPC which you can verify from here so this internet gateway has been created but state is detached so you need to click on this internet gateway go to action go to attach VPC and here you need to select the test VPC which we have just created in the previous step so attached to internet internet gateway and now our internet gateway is ready moving back to our diagram the next block which we need to create over here is the subnet so here we are going to create two subnets both are going to be a public subnet and these are the IP ranges which we are going to assign to those subnets so let's switch back to our uh AWS console and here in the VPC not VPC but on a VPC dashboard you will find an option for a subnet so here you can see these are the subnets click on it so here these are the default subnet which has already been created for you but we don't need to use that we are going to create our own public subnet so click on create subnet over here uh then you need to select the VPC so select test VPC because we are going to work inside our test VPC okay so now we have selected the test VPC and then we need to enter the name of our public subnet so I'm just going to put the name test public subnet 1 a so I'm just going to explain to you why I'm using 1A because I'm present in the Europe Europe zone so that's why I'm using the Europe Central One a that's the availability zone so I'm just going to select that one after that we need to specify the IP range for my public subnet so I'm just going to use the IP range over here so I have just copied and paste so here's the value which I have pasted so 12.1.0 sl24 so I will have a 256 IPS available uh within my Subnet so that's my first public subnet which I have created I need to create a one more public subnet so that we can create two ec2 instances inside those subnet and then we can load balance uh traffic onto those ec2 instan and so that's just an heads up for you okay so here I'm just going to copy another value uh so I just going to paste the name and sorry this is not the correct so I'm just going to copy the name from the top go over here and here I'm just going to change it to 1B so that I can uh provision this subnet into another uh Zone and here I I'm just going to specify the zone that is Europe Central 1B after that I need to specify the IP range so I'm just going to check what IP range I have specified so it's a 12.03 so I'm just going to copy from my notepad go back to my AWS console past the value over here and the tax that's fine I'm just going to click on create subnet and here you can see our subnet has been created if you go back to dashboard and if you click on subnet then here you can see these are the two subnets which we have just created now after creating the subnets we need to create the route table also so that uh this public subnet can have the access to the internet because internet gway and the subnets are still not connected with each other and for that we need a route table so here you will also find the option on the left hand side to create a route table so click on it and here these are the default route table but we are not going to use that one we're just going to create a new one so here I'm just going to put the name of the route table so test public RT RT is the abbreviation for a route table then again we are working in a single VPC so the VPC which we have created is the test VPC I'm just going to select that one the key uh I'm just going to go with the default value and then just click on create route table check the route tables over here so here you can see our route table has been created the next thing which we need to do we need to provide an internet access to this route table and also we need to associate this route table with our subnet so first of all we are just going to associate this route table with our subnets so I'm just going to click on subnet Association go to edit subnets and here you can see our both the subnet which I have created so select both of them and save Association so now this route table is being associated with these subnets but still uh these subnets don't have the access to our internet and for that we need to create a route so here go on to routes inside the route table click on edit routes and here click on ADD route and here you need to enter the IP so this 0.0.0.0 means it will have an internet access and anyone can access those public subnet or any resource present inside that public subnet will be accessible so that's just a heads up for you now we here we need to select the internet gateway because internet gateway is responsible for providing the internet access for this uh route table so I'm just going to select the internet gateway and here you need to you it the internet gateway name will pop up because this is the internet gateway which we have just created so select this internet gateway and after that you can just click on Save changes all right so now this route table has an internet gateway which is to internet and now we are having the subnets also all the public subnets are associated with this particular route tables now after creating the route table let's take a look onto the diagram first and check on the which next block which we are going to create so here these are the things which we have achieved so far we have created the VPC we have created the internet gateway we have created the subnet and we have also created the route table now the next thing which we need to create is we need to create the ec2 instances so we will create two ec2 instances one in first Subnet and another one into another public subnet so we have already created the two public subnet inside our AWS so let's switch back to our AWS console over here and go to D home cons homepage of our AWS console click on E2 or either you can type over here so ec2 over here and here you can see there are no instances running so click on launch instances and here we are just going to put the name test ec2 uh instance one second we need to choose the uh base operating system for that I'm just going to choose u 2 after that uh I need to choose the architecture so I'm just going to go with xx6 I'm just going to choose t2. micro because this is just for demo purpose key pair I'm just going to choose I I'll just create a new key pa uh so test ALB uh demo key payer all right then create key payer and remember once you create this key key PA then here it is going to download this uh key PA for you okay and also it is going to associate this public key so here you can see in the drop down the public key has been associated with our ec2 instance and this is the private key which we have downloaded which we are going to use later okay so now we have created the key pair uh go to network setting this is important because here we need to change few things and the few things I'm talking about is we need to associate our test VPC which we have just created so here from the drop down just select the test VPC which we have created then from the uh drop- down menu you need to select the public subnet so by default it will populate those uh subnet which we have created so first of all for first uh instance I'm just going to go with the uh test public subnet 1 a so that has been selected assign public IP so I'm just going to say enable it yes uh create security groups that's uh important uh because we are just going to create uh some Security Group rules over here so here you can see by default we are allowing the SSH so whenever this ec2 instance start so we will be able to SSH into this ec2 instance on a port 2020 but also we need to enable the port 80 so that we can access uh the Apache which we are going to install onto this ec2 instance so for that click on ADD security Rule and instead of custom TCP we are just going to choose the HTTP and here port 8080 Source type from anywhere so we will be able to access the C2 instance from any anywhere in the world uh so I think that's good so remember we need always we need to create these at least these two security groups one is for SSH and one is for HTTP Port 0 so that it is accessible from outside uh AWS environment all right so that we have done it uh the default storage we are going to go with the 8GB and in the advanced details here we need to do few more things so if you go down then here is the user data section where you can write down the packages which you want to get it installed onto your ec2 machine so if you don't know what is user data then please check the uh previous session where I have explained like what is user data and how you can use the user data to bootstrap or pre-install certain software packages but just to give you a brief I'm just going to copy uh one of my script uh which is I'm just going to show you which is this so here what we are going to do we are just going to update the package manager we just going to install the Apache 2 and after that we are just going to uh update the index.html so that it can print the host name of that ec2 instance so that's the simple thing I just I'm just trying to achieve over here all right so once we are done with all this thing what we are going to do we are just going to click on this launch instance button so click on launch instance okay so here our instance has been launched so click on this instances and here right now it is in a pending state so I'll be back once this instance is up and running so after a minute or so my instance is up and running and here you can see the stat which is running so click on this instance ID and here you will find the public IP so first we need to verify our Apache whether it has been installed or not so I'm just going to copy this address go to browser and hit enter so here you can see uh these are the server detail I'm just going to zoom in a bit over here so that you can see so this is the IP which we are trying to print over here so that we can later on verify uh once we provision the load balancer so that which request is point going to which ec2 instance so this is the internal IP address which you can see 12.01 142 and now this IP range you can uh know that uh this is the same IP range we have specified for our public subnet so now we are getting the IP addresses for our ec2 instance from that particular range okay so I'm just going to close this window over here and I'm just going to click on ec2 so as of now I'm just going to refresh it again so here you can see one instance running so now we have provisioned one E2 instance but we need a one more ec2 instance into another public Su so for that I'm just going to click on this launch instance and here I'm just going to put uh test ec2 instance and I'm just going to put two select Ubuntu then here you just need to select the architectural type I'm just going to go with the default x86 T2 micro and here I'm just going to choose the key paer name which I have just created I think it is test ALB demo key PA network setting I'm just going to edit it uh select the VPC which is test VPC which we have just created and here subnet I'm just going to choose uh 1B okay and here Auto assign enable it uh create Security Group yes we want to create a security group and for that we are just going to go with the default which is SSH 22 because we want to SSH into our E2 instance but also we want to enable the HTTP on a port 80 so and also I just want to exess it from anywhere okay so now we have defined this uh Security Group rule the next thing which we need to do is configure store I'm just going to stick with the default one but in the advanced detail I'm just going to go with the user uh data so here this is the section I'm just going to copy the script to install the Apache and that's been done and after that uh I think it looks good so I'm just going to hit on launch instance okay so click on launch instance all right so let's go back to instances and here you can see it is in pending state so I'll be back once this second instance is up and running all right so now my second instance is is up and running so let's verify a few things over here so I'm just going to copy the IP address which is the public IP address and verify my Apache 2 page so click on it and here you can see I'm just going to zoom in a bit so this is the uh IP uh which has been assigned for this ec2 instance and now it is 12.03 and then 160 so it's again coming from the default IP range which we have assigned for our another public subnet and which you can verify from here also so here you can see the same IP which is available over here so now we have provision our ec2 instances and now we have installed the Apache but we have not yet configured the target Group which we are going to do the next but before we create a Target group let's take a look onto our architectural diagram so here you can see we have achieved so far like VPC internet gateway subnets and also we have provisioned the ec2 instances so now what we need to do we just need to create our Target group so Target group is just a logical unit where we are going to Club these ec2 instance into this single Target groups so that later on elastic uh load balancer can point to this particular Target group I know it sounds complicated but let's take a look onto our AWS console and then we you're are going to understand what I'm trying to say over here all right so this is my ec2 dashboard so click on this ec2 dashboard homepage and on the left navigation menu there is a option for load balancing and inside the load balancing there is a option for a Target group creation so click on target group and here you can see this section is empty so we need to create a Target group and inside that Target group we need to include both the ec2 instances so first of all let's click on create Target group here there are certain types of Target Group which you can create but for this example we are just going to stick with the uh ec2 instance or instances type Target group so just select this one go ahead and here you need to enter the name so I'm just going to put the test uh ec2 ALB demo Target group so TG is for abbreviation IP address type so I'm just going to stick with ip4 uh VPC because everything we are doing into the test VPC so we need to select the test VPC over here protocol version I'm just going to stick with HTTP 1 uh the health check endpoint I'm just going to go with the default route because uh as you can see uh we are just able to access our homepage uh and we don't have any path uh which is like this so we don't need to specify anything so I'm just going to go with the root path okay go ahead Advanced salth check setting I'm just going to stick with the default we don't need to change it tags it's optional so I'm just going not going to assign any tag name click on next over here and as soon as you click next then you can see all the ec2 instances running uh which are ready to be included so here you can see uh here you can select the ec2 instances which you want to include so I'm just going to select these and both of the ec2 instances are running and now I have selected both of it now after selecting you need to click on include as a pending below so here uh it will be included and it will be accessible on a port 18 so I'm just going to click include as pending below and here you can see these targets are now included and after that you just need to click on the create Target group so click on this create Target group over here and here you can see our Target group has been created so click on this create Target group and uh yeah so as of now the health status is unused as you can see over here but you just need to wait for a couple of minute and the health status should change to healthy one correction I'd like to make over here so here you can see the health status is unused because we have not created the application load balancer so once we create the application load balancer then these status will change so now what we need to do we just need to create our application load balancer but before we create our application load balancer let's take a look onto our architectural diagram so here you can see uh we have come far away so we have created VPC internet gateway public subnet private subnet we have provisioned the ec2 instance and also we have have created a targeted group now the next component which we need to create is we need to create a application load balancer so let's go back to our application console AWS console and here click on ec2 dashboard and in the left navigation you will find option for a load balancing and here you will find the option for a load balancer so click on this load balancer and here you can see there are no load balancer has been created so click on this load balancer button and here you will find the three types of load balancer which is application load balancer Network load balancer and Gateway load balancer but here we are only interested into application load balancer uh so we are just going to choose this one okay so click on create over here so now what we need to do first of all we need to assign the name for a load balancer so I'm just going to assign the test uh lb for ec2 demo okay so that's the name uh the scheme is internet facing so yes we want to have it as an internet facing load balancer into the network mapping and as I have told many times we are just working under a VPC which we have created and the name of the VPC is test VPC so in the drop down you will find a test VPC just select that one and once you create select the test VPC then you will automatically get the subnets which we have created so here we have created the one public subnet which is in EU Central 1 a and another one we need to select both of it otherwise our application load balancer will not work okay the next thing which we need to create over here is the secur Security Group so there is a one default Security Group which has been created but we need to create a one more Security Group for Port 80 and for uh accepting the HTTP request so for that what I'm just going to do I'm just going to click on this create Security Group over here and I'm just going to put Security Group uh for lb ALB demo and uh allow access from internet that's the description I'm just going to put here we need to choose the VPC info so here if you click on this one then I'm just going to choose test VPC inbound rule add click here and type HTTP and here I'm just going to choose the port 80 and Source I'm just going to put 0000 0 so that anyone from anywhere can access this load balancer okay so that this Security Group has been created I'm just going to copy this security group name because that will be needed to add the security group and I'm just going to click on create Security Group uh cannot begin with SG okay so I need to change it okay so let's put Security Group for Alp demo and I'm just going to click on create Security Group all right so this Security Group has been created I'm just going to copy this name from here and I'm just going to close this window I'm just going to refresh this page over here and here we should find that Security Group so that's the security group which we have just created select that one so now we have selected the default as well as the security group for allowing the HTTP request on a port 80 all right now here uh in the listeners and routing so here we need to select the target group so let's take a look onto the diagram once again so that it's easy to understand so here in the green box which is you can see this is our Target group so this target group we need to select for this load balancer and this target group which we have already created so if you go over here in the Target group so here you can see so this is the target Group which we have already created and inside the target group we have both the instances uh ec2 instances running so I'm just going to copy this name from here and into this listener routing I'm just going to select here you can see it is by default coming because that's the only target group I have inside my uh AWS account so I'm just going to select that one and the listener tag is optional so I'm just going to skip that one uh addon services are optional so I'm just going to skip that one so here just take a look onto this summary over here so the basic configuration for this Auto uh application load balancer is this is a internet facing this is an ip4 Security Group uh we are allowing the HTTP at this is the security group which we have created this is the default one so I'm just not going to change that one so this is the VPC and this VPC is test VPC and these are the subnets uh the two subnet which I have created which are public subnet and this is the target group so this is the target group inside where we are having two ec2 instance running all right so now we can just click on create load balancer and as you can see successfully created the load balancer so just go on to load balancer tab once again and here just wait for a couple of minute because it's still into the provisioning state so it might take a couple of minute to provision this whole load balancer so I'll be back once this autoload balance application load Bal bancer is up and running all right so after a couple of minute my uh application load balancer is in active state so click on this application load balancer over here and here you will find the details and the detail which we are looking for is the DNS name so that we can access that application load balancer so here you can see the DNS name which is present so you can just copy this DNS name from here uh go to the new tab and hit enter and here you can see uh I'm just going to zoom in a bit so so that you can see so now the request has been routed to the uh ec2 instance 2 I'm just going to refresh it once again so here you can see the uh request is landing on another ec2 instance because the IP address has been changing so again refresh it so here you can see the IP address has been changed and we can verify the ec2 instances here also just to reconfirm what's the IP address so ec2 instances so I'm just going to open this one and this one so the instance IP address I'm just going to zoom in a bit if you this to small so 12.3.1 160 and another one is uh 12.01 sl. 142 so these are the two IP address and if I refresh this so the request is going to the 1/42 and then another one another request is going to the 3/60 so that's how we just going to set up the application load balancer and that application load balancer is responsible for sharing the request between the ec2 instances which you have set up inside your VPC so let's take a look onto the architectural diagram once again so this was the target architectural diagram and the last pieces were just nothing it was just a few arrows so here this was the user and it is accessing the application load balancer and the requests are being routed to both the ec2 instances so here you can see uh and the user is us and this is the DNS name uh through which we are accessing the application load balance and then the request is getting routed to both the ec2 instances I hope you like the today's session on application load balancer and if you are interested into the similar content then please check the description section where I have posted the links of various courses like terraform Helm chart kubernetes doer uh so those are already available onto this channel so go and check those uh courses and there are many more session on AWS which I have planned which I'll be uploading into the upcoming weeks and if you are interested into the more in-depth devops practices and devops project then I have a YouTube uh Channel membership uh which you can be a part of and where you will see a more in-depth uh like a projects which I keep on uploading onto for only for the members so if you are interested then please considering subscribing to the YouTube channel membership for my channel also so see you into the next session of a devops or AWS C is still then take care and bye-bye
Info
Channel: Rahul Wagh
Views: 25,019
Rating: undefined out of 5
Keywords: aws, ALB, application load balancer, devops, cloud
Id: cuJTmBvFCS0
Channel Id: undefined
Length: 25min 24sec (1524 seconds)
Published: Wed Oct 18 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.