AWS ELB with Autoscalingv6

.docx
School
Austin Community College District**We aren't endorsed by this school
Course
ITNW 1335
Subject
Information Systems
Date
Dec 17, 2024
Pages
14
Uploaded by CommodoreAtomDeer31
AWS – ALB with Auto ScalingCreate an Application Load Balancer1.Make sure you’re in the N. Virginia region and navigate to EC2> Load Balancers.2.Click Create Load Balancer.3.Click the Createbutton under the Application Load Balancerand set the following values:oName: yourlastname-alboScheme: internet-facingoIP address type: ipv44.Under Network Mapping:oLeave Default VPC.oAdd 4 Availability Zones, like us-east-1a, us-east-1b, us-east-1c, and us-east-1dto your ALB.5.Under Security groups, select to Create a new security group(new tab opens) for your ALB, and set the following values:oName: yourlastname-alb-sgoDescription: Security group for Application Load Balancer Linux WebserveroClick Add ruleand under Inbound rules, select under TypeHTTP and SourceAnywhere-IPv4 oAdd a new tag Key/Valueof Name/yourlastname-alb-sgoClick Create security group oGo to your browser tabs and find your Load Balancer (should be previous tab)oAt Security groups, in the dropdown, select the security group you just created. If you don’t see it, click the refresh icon.oClick the X to delete the default sg6.UnderListeners and routingclick Create target group(new tab opens) and enter the following values:oChoose a Target type: InstanceoTarget group Name: yourlastname-alb-tgoExpand Advanced health check settings, and reduce the Healthyand Unhealthythreshold checks down to 2.oClickNextoClickCreate target groupoGo back to the Load Balancer tab and add the target group. Click the refresh icon if it doesn’t show.
Background image
7.Scroll down to the bottom an verify the Summary8.Click Create load balancer.9.Copy the DNS nameassociated with the load balancer under Details, open in a new browser tab, and paste it. You should see a 503 error since we don’t have any operational EC2 instances associated with the load balancer.Create a Launch TemplateCreate a launch template that will be used by the Auto Scaling group. The launch template defines what the instances are and how they are created. You can use the previous lab Creating an EC2 Auto Scaling Groupwith the following information:1.Navigate to EC2> Instances> Launch Templates.2.Create a new template, and call it yourlastname-alb-ltfor the name and description.3.Check the Provide guidance……checkbox.4.Click Quick Startunder Application and OS Imagesand pick the Amazon Linux 2 AMI (64-bit x86).5.Set the instance type as t2.micro.6.Select the key pair you created for your webserver in previous labs.7.Under Network Settingsfor Subnetleave “Don’t include in launch template”.8.Select the webserver-sgsecurity group you created in an earlier lab.9.Storage should automatically be populated with a volume, so leave that as default and don’t add anything to the network section.
Background image
10.Add Resources Tags of Keyof Nameand Valueof yourlastname-alb-lt. Expand Advanced Details, do the following: A) Set the Metadata versionto V1 and V2B) Paste the following User datain the box.#!/bin/bashyum update -y yum install httpd -y service httpd start chkconfig httpd on cd /var/www/htmlinstance_id=$(curl http://169.254.169.254/latest/meta-data/instance-id) availability_zone=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone) echo "<html><h1>Welcome to yourlastnameAutoScaling site</h1>" >index.htmlecho "<h1>page generated by instance <strong>$instance_id</strong> in availability zone <strong>$availability_zone</strong></h1> " >>index.htmlecho "<head> ">>index.htmlecho "<meta charset=\"UTF-8\"> ">>index.htmlecho "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"> ">>index.htmlecho "<meta name=\"viewport\" content=\"width=device-width, initial scale=1.0\"> ">>index.htmlecho "<h1> Time is <span id=\"time\"> </span></h1> ">>index.htmlecho "<script src=\"index.js\"> </script> ">>index.htmlecho "</head> ">>index.htmlecho "</html>">> index.html echo " \`use strict\` ">index.jsecho "var datetime = new Date(); ">>index.jsecho "console.log(datetime); ">>index.jsecho "document.getElementById(\"time\").textContent = datetime; ">>index.jsamazon-linux-extras install epel -y yum install stress -y MAKE SURE THIS LINE IS WHERE YOUR CURSOR IS AFTER PASTE. REMOVE THE WORDS11. Click Create Launch Template.12. Click View Launch Template.Create an Auto Scaling GroupYou can use the previous lab Creating an EC2 Auto Scaling Groupwith the following information:
Background image
1.EC2> Auto Scaling> Auto Scaling Groups2.Click Create Auto Scaling group.3.Call the group yourlastname-alb-asg.4.Select Launch Template, and choose the template you just created and click Next.5.Pick the default VPC, select Availability zones us-east-1a, us-east-1b, us-east-1c, and us-east-1d(or the ones selected when creating the Load Balancer) as subnets and click Next.6.Under Load balancing, checkAttach to existing load balancing.7.Check Choose from your load balancer target groupand select target group yourlastname-alb-tg.8.Under Health checks, check Turn on Elastic Load Balancing health checks.
Background image
9.Click Next.10. For Group Size, enter the following values:oDesired Capacity: 2oMinimum Capacity: 2oMaximum Capacity: 411.For Automatic scaling, select Target tracking scaling policyand enter the following values:oScaling Policy Name: Target Tracking PolicyoMetric type: Average CPU utilizationoTarget value: 50
Background image
oInstances need: 12012. Click Next.13.ForAdd notification, we can use this to send emails when a new instance is triggered by one the auto scaling metrics selected. Leave the default then chooseNext.
Background image
14.Under TagschooseAdd tag, provide a tag key Nameand value yourlastname-alb-asgand then chooseNext.15. Click Create Auto Scaling Group.16.On the Auto Scaling group page, check the box next to your newly created group.
Background image
17.Select the Activitytab and scroll down to History to see instances being created.18.Go to EC2>Instancesto see you 2 instances coming up. Wait until the Status Check passed.Attempt to Connect to Website1.Now it time to test the Web pages and load balancer. Open a Incognito or Private Window (tab)2.Go to EC2>Load Balancer and copy the DNS of the load balancer, paste the URL in your private browser, and hit Enter. Screenshot this page and paste into a Word doc (yourlastname_ALB-ASG-Lab.docx) under the heading Initial Load Balance Test 1. Note the Availability Zone.
Background image
3.Hit the Refresh icon on your browser. If your Load Balancer is working, your AZ should change. Screenshot this page and paste into a Word doc (yourlastname_ALB-ASG-Lab.docx) under the heading Initial Load Balance Test 2. If you hit refresh multiple times, it should toggle back and forth between the 2 instances.
Background image
Test Horizontal Scaling1.In order to trigger scaling, we need to stress the CPUs on the two running instances. First, go to Auto Scaling Groups under EC2>Auto Scaling2.Check the box next to your need Auto Scaling Group then go to the Monitoring (EC2)tab below. This should show the two instances CPU utilizations (they are color coded). Both should be pretty low. The picture below shows the same thing from the EC2>Instancesscreen. Here, one instance is check and CPU monitored.3.Go to EC2>Instancesand connect to the EC2 instance in AZ 1a(or the first instance) by checking the box and hitting the Connectbutton. On the next screen under EC2 Instance Connect, click the Connect
Background image
button. A terminal window should open in the browser.4.In the Terminal window, type stress -c 10. This command will start the stress CPU process and cause horizontal scaled when the CPUs crosses 50%.5.Repeat steps 3 & 4 for the instance in 1b (or whatever your second instance is).6.Now go back the EC2>Instances, check the boxes next to your 2 running instances, and look at the CPU utilization % under Monitor tab. Hit refresh a few times and you’ll see the CPU utilizations rise.7.Go to the Activities tabto see new instances will be added. Hit refresh a few times to see this.
Background image
8.Now go to EC2>Instances to see the newly created instances starting up.9.After the Status Checks are green, screenshot this page and paste into a Word doc (yourlastname_ALB-ASG-Lab.docx) under the heading Horizontal Scaling.10.Now return to your browser window and hit the refresh button. You should now see each of the 4 Web server instances. Refresh and screenshot each page showing the different instances and paste intoa Word doc (yourlastname_ALB-ASG-Lab.docx) under the heading Final Load Balancer Test.
Background image
Clean up1.After capturing all screenshot, delete the Auto Scaling Group (This will terminate the instances automatically) and the Load Balancer.2.Make sure the instances are terminated before logging out.
Background image
3.Save and upload your Word Doc to Blackboard for credit.
Background image