AWS Elastic Load Balancing Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(44 intermediate revisions by the same user not shown)
Line 5: Line 5:
* [[AWS Elastic Load Balancing#Subjects|AWS Elastic Load Balancing]]
* [[AWS Elastic Load Balancing#Subjects|AWS Elastic Load Balancing]]


=Create a Network Load Balancer=
=Load Balancer Operations=


Go to Amazon EC2 console -> Load Balancers -> Create Load Balancer -> Network Load Balancer.
==Describe Load Balancers==


==Basic Configuration==
aws [--region ca-central-1 ...] elbv2 describe-load-balancers


[[AWS_Elastic_Load_Balancing_Concepts#Load_Balancer_Name|Name]]: playground-internal-lb (it should not start with "internal-...").
==Elastic Load Balancing V2 Deployment with CloudFormation==


[[AWS_Elastic_Load_Balancing_Concepts#Load_Balancer_Scheme|Scheme]]: internal/internet-facing: internet-facing.
{{Internal|AWS Elastic Load Balancing V2 Deployment with CloudFormation|Elastic Load Balancing V2 Deployment with CloudFormation}}


==Listeners==
==Create a Network Load Balancer==


The default [[AWS_Elastic_Load_Balancing_Concepts#Listenerl|istener]] uses TCP over port 80.
* [[AWS Elastic Load Balancing Operations Create a Network Load Balancer with Amazon Console|Create a Network Load Balancer with Amazon Console]]


==Availability Zones==
==Test a Network Load Balancer==


Specify the VPC in which the targets exist.
curl http://playground-nlb-85d74951c7b728b3.elb.us-west-2.amazonaws.com:10001/amazons


Specify at least one, possible more availability zones and one subnet per availability zone.
==Create an Application Load Balancer==
* [[AWS_Elastic_Load_Balancing_V2_Deployment_with_CloudFormation#Create_an_Application_Load_Balancer|Create an Application Load Balancer with CloudFormation]]


For more details: {{Internal|AWS_Elastic_Load_Balancing_Concepts#Load_Balancer_and_Availability_Zones|Load Balancers and Availability Zones}}
==Application Load Balancer GetAtt Attributes==


==Security Settings==
{{External|[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html GetAtt]}}


<font color=darkgray>Return here.</font>
* DNSName


==Configure Routing==
==Connecting Internet-Facing Load Balancer to Private IP Address Targets==


If this load balancer is created to service ECS FARGATE containers that have not been defined yet, that is fine, the target groups will be created during the [[Amazon_ECS_Operations#Load_Balancing|ECS Service creation process]].
{{Internal|AWS Elastic Load Balancing Connecting Internet-Facing Load Balancer to Private IP Address Targets|Connecting Internet-Facing Load Balancer to Private IP Address Targets}}


===Target Group===
=Register a Target with a Target Group in Command Line=


[[AWS_Elastic_Load_Balancing_Concepts#Target_Group|Target Group]]: New target group
aws elbv2 register-targets --target-group-arn arn:aws:elasticloadbalancing:us-west-2:77777777777:targetgroup/themyscira/4d66315292d681f9 --targets Id=10.7.1.84 Id=10.7.1.151


Name: something
=Listener Operations=


[[AWS_Elastic_Load_Balancing_Concepts#Target_Type|Target type]]: Instance
aws [--region ...] elbv2 describe-listeners <--load-balancer-arn ... | --listener-arns ...>


[[AWS_Elastic_Load_Balancing_Concepts#Target_Group_Protocol|Protocol]]: TCP
aws --region ca-central-1  elbv2 describe-listeners --listener-arns arn:aws:elasticloadbalancing:ca-central-1:777777777777:listener/app/infinity-test-alb/ac8ae6a4de687154/4c3e44faee30b5d2


[[AWS_Elastic_Load_Balancing_Concepts#Target_Group_Port|Port]]: 10001
=Target Groups Operations=


===Health Checks===
<syntaxhighlight lang='yaml'>
Resources:
  ...
  TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    #
    # DependsOn is important, I've seen race conditions with the load balancer
    #
    DependsOn: ApplicationLoadBalancer
    Properties:
      Name: !Sub ${Color}-themyscira-tg
      VpcId: !Ref VPC
      Protocol: HTTP
      Port: !Ref ApplicationPort
      TargetType: ip
      HealthCheckProtocol: HTTP
      HealthCheckIntervalSeconds: 60
      HealthCheckTimeoutSeconds: 10
      HealthyThresholdCount: 3
      UnhealthyThresholdCount: 3
      HealthCheckPath: '/actuator/health'
</syntaxhighlight>


<font color=darkgray>Return here.</font>
=Troubleshooting=


==Register Targets==
==Application Load Balancer Troubleshooting==
 
{{External|[https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html Troubleshoot Your Application Load Balancers]}}
===Registered Targets===
 
===Instances===
 
<font color=darkgray>If the load balancer is created before the ECS deployments, how do I select those?</font>
 
==Network Load Balancers and ECS FARGATE Instances==
 
=Test a Network Load Balancer=
 
=Create an Application Load Balancer=

Latest revision as of 20:56, 1 May 2019

External

Internal

Load Balancer Operations

Describe Load Balancers

aws [--region ca-central-1 ...] elbv2 describe-load-balancers

Elastic Load Balancing V2 Deployment with CloudFormation

Elastic Load Balancing V2 Deployment with CloudFormation

Create a Network Load Balancer

Test a Network Load Balancer

curl http://playground-nlb-85d74951c7b728b3.elb.us-west-2.amazonaws.com:10001/amazons

Create an Application Load Balancer

Application Load Balancer GetAtt Attributes

GetAtt
  • DNSName

Connecting Internet-Facing Load Balancer to Private IP Address Targets

Connecting Internet-Facing Load Balancer to Private IP Address Targets

Register a Target with a Target Group in Command Line

aws elbv2 register-targets --target-group-arn arn:aws:elasticloadbalancing:us-west-2:77777777777:targetgroup/themyscira/4d66315292d681f9 --targets Id=10.7.1.84 Id=10.7.1.151

Listener Operations

aws [--region ...] elbv2 describe-listeners <--load-balancer-arn ... | --listener-arns ...>
aws --region ca-central-1  elbv2 describe-listeners --listener-arns arn:aws:elasticloadbalancing:ca-central-1:777777777777:listener/app/infinity-test-alb/ac8ae6a4de687154/4c3e44faee30b5d2

Target Groups Operations

Resources:
  ...
  TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    #
    # DependsOn is important, I've seen race conditions with the load balancer
    #
    DependsOn: ApplicationLoadBalancer
    Properties:
      Name: !Sub ${Color}-themyscira-tg
      VpcId: !Ref VPC
      Protocol: HTTP
      Port: !Ref ApplicationPort
      TargetType: ip
      HealthCheckProtocol: HTTP
      HealthCheckIntervalSeconds: 60
      HealthCheckTimeoutSeconds: 10
      HealthyThresholdCount: 3
      UnhealthyThresholdCount: 3
      HealthCheckPath: '/actuator/health'

Troubleshooting

Application Load Balancer Troubleshooting

Troubleshoot Your Application Load Balancers