Target Group

더쿠·2024년 12월 5일
0

참고

Target groups for your Application Load Balancers - Elastic Load Balancing

설명

  • Target Group은 Elastic Load Balancer와 함께 사용되는 중요한 구성 요소로 Load Balancer의 Routing Rule에 따라서 알맞은 Target(예: Instance, Port)으로 트래픽을 전달하는 역할을 수행합니다.

  • Target Group은 VPC Level의 서비스입니다.

    • Target GroupdTarget Group과 Load Balancer 연결 시, VPC가 동일해야 합니다. VPC가 각각 다르다면 연결이 불가능합니다.
  • Target Group의 Target Type으로 Instance, IP, Lambda, Application Load Balncer를 사용할 수 있습니다.

    • Instance 타입은 일반적으로 가장 많이 사용되는 타입으로 Instance ID를 기반으로 Target Group에 등록됩니다.
      • Target Group에 등록할 Target이 Load Balancer와 동일한 VPC에 위치한 경우 적절합니다.
  • Target Group 생성 시, Load Balancer가 트래픽을 어떤 ProtocolPort를 사용하여 Target으로 전달할 것인지 지정할 수 있습니다.

    • 예를 들어 Load Balancer가 443 Port를 Listening 하고, Target에서 실행중인 Application은 8080 Port를 사용하여 서비스를 하고 있다면, Target Group 설정 시, Protocol(예: HTTP..)과 Port(예: 8080..)을 지정하여 전달되도록 설정할 수 있습니다.
    • Target Group 생성 시, 지정한 Protocol, Port는 수정이 불가능합니다. 하지만 Target 등록 시 트래픽을 전달할 Port를 수정할 수 있습니다.
      만약 Auto Scaling Group과 Target Group을 함께 사용하는 경우, Auto Scaling Group에 의해서 인스턴스가 자동으로 생성될 때, Target 등록 시 지정한 Port가 아니라, Target Group 생성 시 지정한 Protocol, Port를 기반으로 Target Group에 등록되기 때문에 주의가 필요합니다.



TarGroup 생성 및 Target(Instance) 등록 예시

1.Target Group 생성합니다.

aws elbv2 create-target-group \
--name <Target_Group_Name> \
--protocol HTTP \
--port 80 \
--vpc-id <VPC_ID> \
--target-type instance \
--health-check-protocol HTTP \
--health-check-port 80 \
--health-check-path / \
--health-check-interval-seconds 30 \
--health-check-timeout-seconds 5 \
--healthy-threshold-count 5 \
--unhealthy-threshold-count 2 \
--matcher HttpCode=200-299 



2.Target Group에 Target을 등록합니다.

aws elbv2 register-targets \
--target-group-arn <Target_Group_ARN> \
--targets Id=i-0aa5de1e416ade697 Id=<Instance_ID>
profile
궁금한게 많은 사람

0개의 댓글