Followers

AWS - Elastic Load Balancer (ELB) Theory + Lab

 Elastic Load Balancer Elastic Load Balancing automatically distributes your incoming traffic across multiple targets, such as EC2 instances...

 Elastic Load Balancer

Elastic Load Balancing automatically distributes your incoming traffic across multiple targets, such as EC2 instances, containers, and IP addresses, in one or more Availability Zones.

 It monitors the health of its registered targets and routes traffic only to the healthy targets.


Classic Load Balancer Lab

1. Create 2 EC2 instances with User Data to install httpd.

    userdata script

#!/bin/bash

sudo yum update -y

sudo yum install -y httpd

sudo systemctl start httpd

sudo systemctl enable httpd

2. Connect to first EC2 instance and run below commands

     echo "<h1>Server 1 </h1>" >> /var/www/html/index.html

3. Connect to second Ec2 instance and run below command

   echo "<h1>Server 2 </h1>" >> /var/www/html/index.html

4. Goto LoadBalancing and Select Load Balancers

5. Click on Create Load Balancer and Select Classic LoadBalancer and Click on Create button.

6. Define LoadBalancer Properties.

   Load Balancer Name:  CLB

   The rest of the properties leave as it is, I am creating in the default VPC and Load Balancer Protocol is HTTP becuase in my EC2 instances the service is running on Port 80 with HTTP protocol.

Click on Next button

7. Select the security Group :- Webserver (Any SG which has port 80 opened) and click on Next

8. No Change on this page, you may see a warning that the application is using insecure protocol HTTP click Next button.

9. Configure Health Check for EC2 instances and Click on Next button

10. Add EC2 instances and Add both Ec2 instances and click on Next Button

11. Tags No Change and Review and Create .

12. Once CLB is created then it will have it defined properties, You can access the CLB using its DNS.

13 Use DNS Name on browser and check it will be connected to server1 and server2 frequently.


Application Load Balancer

Elastic Load Balancing automatically distributes your incoming traffic across multiple targets, such as EC2 instances, containers, and IP addresses, in one or more Availability Zones. It monitors the health of its registered targets, and routes traffic only to the healthy targets. Elastic Load Balancing scales your load balancer as your incoming traffic changes over time. It can automatically scale to the vast majority of workloads.

1. Create 2 EC2 instances with User Data to install httpd.

    userdata script

#!/bin/bash

sudo yum update -y

sudo yum install -y httpd

sudo systemctl start httpd

sudo systemctl enable httpd

2. Connect to first EC2 instance and run below commands

     cd /var/www/html

     mkdir orders

     cd orders

     echo "<h1> Orders App </h1> >> index.html


2. Connect to second EC2 instance and run below commands

     cd /var/www/html

     mkdir payments

     cd payments

     echo "<h1> Payments App </h1> >> index.html

3. Define the target groups which helps to route request to appropriate application.

Select Target Group from Load Balancer Menu and Define below properties

  •   Target Type : Instances
  •   Target Group Name: OrdersTG
  •  Protocol HTTP: 80
  • VPC : default vpc
  • Protocol Version: Http1
  • Health check Path: /index.html

Click on Next button

  •    Register Targets
  •      Select first Ec2 instance
  •      Click on Include Pending Below

and Click on Create Target Group


Select Seond Target Group from Load Balancer Menu and Define below properties

  •   Target Type : Instances
  •   Target Group Name: PaymentsTG
  •  Protocol HTTP: 80
  • VPC : default vpc
  • Protocol Version: Http1
  • Health check Path: /index.html

Click on Next button

  •    Register Targets
  •      Select sec Ec2 instance
  •      Click on Include Pending Below

and Click on Create Target Group

Step 4: Create Application Load Balancer

 Click on Create Loadbalancer Button

  •  Select Application Load Balancer and Click on Create
  • Load Balancer Name: ALB
  • Mappings :- Select all the AZs
  • VPC : default
  • Security Group: WebserverSG
  • Default Listner : Port: 80 Default action:  OrdersTG

Click on Create Load Balancer Button

Step 5: Load Balancer should be created and it should have a DNS Name by which you are connecting to the applications. Copy the DNS name and put it in the browser, you should be able to see the default apache web page which is implemented in the First Ec2 instance.

Step 6: Select Listenter tab for ALB and click on view/edit rules link

   Click on + symbol on this page and then Insert Rule link

   Set below properties for the rule

    Path : /orders*

   Forward to : OrdersTG

and Click on Save


   Click on + symbol on this page and then Insert Rule link

   Set below properties for the rule

    Path : /payments*

   Forward to : PaymentsTG

and Click on Save

Step 7: Goto browser and put dnsname of ALB/ordres and /payments it should redirect to respective application





COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,git quiz,1,Git Worksheet,1,ITIL,1,ITSM,1,Jira,3,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SDLC Quiz,5,SonarQube,3,Splunk,2,vagrant kubernetes,1,Windows,1,YAML Basics,1,
ltr
item
DevOpsWorld: AWS - Elastic Load Balancer (ELB) Theory + Lab
AWS - Elastic Load Balancer (ELB) Theory + Lab
DevOpsWorld
https://www.devopsworld.co.in/2022/03/aws-elastic-load-balancer-elb-theory-lab.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/03/aws-elastic-load-balancer-elb-theory-lab.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content