Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
© 2022 Yandex.Cloud LLC
Yandex Network Load Balancer
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Network load balancers
      • Create a network load balancer
      • Create an internal network load balancer
      • Start a load balancer
      • Stop a load balancer
      • Delete a load balancer
      • Check target health statuses
      • Add a listener
      • Delete a listener
    • Target groups
      • Create a target group
      • Attach a target group to a load balancer
      • Detach a target group from a load balancer
      • Delete a target group
  • Concepts
    • Network load balancer
    • Internal network load balancer
    • Listener
    • Targets and groups
    • Resource health checks
    • Quotas and limits
  • Best practices for using the service
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • NetworkLoadBalancerService
      • TargetGroupService
      • OperationService
    • REST
      • Overview
      • NetworkLoadBalancer
        • Overview
        • addListener
        • attachTargetGroup
        • create
        • delete
        • detachTargetGroup
        • get
        • getTargetStates
        • list
        • listOperations
        • removeListener
        • start
        • stop
        • update
      • TargetGroup
        • Overview
        • addTargets
        • create
        • delete
        • get
        • list
        • listOperations
        • removeTargets
        • update
      • Operation
        • Overview
        • get
  • Questions and answers
  1. Step-by-step instructions
  2. Target groups
  3. Attach a target group to a load balancer

Attach a target group to a network load balancer

Written by
Yandex Cloud
    Management console
    CLI
    API

    To attach a target group to a network load balancer:

    1. In the management console, select the folder where you wish to attach a target group to a load balancer.
    2. In the list of services, select Network Load Balancer.
    3. In the line of the load balancer to attach a target group to, click and select Attach target group.
    4. Select a target group or create a new one.
    5. Configure health check settings.
    6. Click Attach target group.

    If you don't have the Yandex Cloud command line interface, install it.

    The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

    1. View the description of the CLI command to attach a target group to a network load balancer:

      yc load-balancer network-load-balancer attach-target-group --help
      
    2. Get the list of load balancers:

      yc load-balancer network-load-balancer list
      

      Result:

      +----------------------+--------------------+-------------+----------+----------------+------------------------+----------+
      |          ID          |        NAME        |  REGION ID  |   TYPE   | LISTENER COUNT | ATTACHED TARGET GROUPS |  STATUS  |
      +----------------------+--------------------+-------------+----------+----------------+------------------------+----------+
      ...
      | b7r97ah2jn5rmo6k1dsk | test-load-balancer | ru-central1 | EXTERNAL |              1 |                        | INACTIVE |
      ...
      +----------------------+--------------------+-------------+----------+----------------+------------------------+----------+
      
    3. Get a list of target groups:

      yc load-balancer target-group list
      

      Result:

      +----------------------+-------------------+---------------------+-------------+--------------+
      |          ID          |       NAME        |       CREATED       |  REGION ID  | TARGET COUNT |
      +----------------------+-------------------+---------------------+-------------+--------------+
      ...
      | b7roi767je4c574iivrk | test-target-group | 2018-12-03 14:41:04 | ru-central1 |            1 |
      ...
      +----------------------+-------------------+---------------------+-------------+--------------+
      
    4. Select the ID or NAME of the required load balancer and target group.

    5. Attach the appropriate group to the selected load balancer by specifying the health check settings in the corresponding command parameters:

      yc load-balancer network-load-balancer attach-target-group b7r97ah2jn5rmo6k1dsk \
        --target-group target-group-id=b7roi767je4c574iivrk,healthcheck-name=test-health-check,healthcheck-interval=2s,healthcheck-timeout=1s,healthcheck-unhealthythreshold=2,healthcheck-healthythreshold=2,healthcheck-http-port=80
      

      Mind the healthcheck-interval and healthcheck-timeout parameter format: the values must be in Ns format.

      For more information about check parameters, see Resource health check.

    You can attach a target group to a network load balancer using the attachTargetGroup API method.

    Was the article helpful?

    Language / Region
    © 2022 Yandex.Cloud LLC