ELB

AWS provides a powerful software-based load balancer called classic load balancer. This was known as Elastic Load Balancer (ELB), which allows you to load balance network traffic to one or multiple EC2 instances. In addition, ELB can offload SSL/TLS encryption/decryption and it supports multi-availability zone.

So, why is it a classic load balancer in particular? This is because AWS introduced new types of load balancers: network load balancer (for L4) and application load balancer (for L7). Therefore, ELB became classic. However, while ELB is stable and robust, Amazon EKS will use load balancer by default, so we keep using ELB.

In the following example, an ELB is created and associated with a public subnet host, nginx (80/TCP). Because ELB also needs a security group, create a new one for this, first:

// Create New Security Group for ELB
$ aws ec2 create-security-group --vpc-id vpc-0ca37d4650963adbb --group-name elb --description "elb sg"
{
"GroupId": "sg-024f1c5315bac6b9e"
}

// ELB opens TCP port 80 for all IP addresses (0.0.0.0/0)
$ aws ec2 authorize-security-group-ingress --group-id sg-024f1c5315bac6b9e --protocol tcp --port 80 --cidr 0.0.0.0/0


// create ELB on public subnets $ aws elb create-load-balancer --load-balancer-name public-elb --listeners Protocol=HTTP,LoadBalancerPort=80,InstanceProtocol=HTTP,InstancePort=80 --subnets subnet-09f8f7f06c27cb0a0 subnet-026058e32f09c28af --security-group sg-024f1c5315bac6b9e
{
"DNSName": "public-elb-1952792388.us-east-1.elb.amazonaws.com"
}

// Register an EC2 instance which runs nginx $ aws elb register-instances-with-load-balancer --load-balancer-name public-elb --instances i-0f2750f65dd857e54

// You can access to ELB from your laptop
$ curl -I public-elb-1952792388.us-east-1.elb.amazonaws.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 3520
Content-Type: text/html
Date: Mon, 17 Dec 2018 06:05:45 GMT
ETag: "5bbfda61-dc0"
Last-Modified: Thu, 11 Oct 2018 23:18:57 GMT
Server: nginx/1.12.2
Connection: keep-alive ...

Overall, we've discussed how to configure AWS components. The following is a summary and diagram about major components and relationships:

  • One VPC that has an Internet Gateway (IGW)
  • Two subnets (public and private) on us-east-1a
  • Two subnets (public and private) on us-east-1b
  • One NAT-GW
  • One public EC2 instance on public subnet with EBS
  • One private EC2 instance on private subnet
  • ELB that forwards the traffic to a public EC2 instance

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset