Attach a target group to a load balancer

    To attach a target group to a load balancer:

    1. Open the Load Balancer section in the folder where you want to attach the target group to the load balancer.
    2. Click image in the row of that load balancer. If you already have a target group created, select it. If not, create one.
    3. Configure health check settings.
    4. Click Attach

    If you don't have the Yandex.Cloud command line interface yet, 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. See the description of the CLI's attach target group command:

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

      $ yc load-balancer network-load-balancer list
      +----------------------+--------------------+-------------+----------+----------------+------------------------+----------+
      |          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
      +----------------------+-------------------+---------------------+-------------+--------------+
      |          ID          |       NAME        |       CREATED       |  REGION ID  | TARGET COUNT |
      +----------------------+-------------------+---------------------+-------------+--------------+
      ...
      | b7roi767je4c574iivrk | test-target-group | 2018-12-03 14:41:04 | ru-central1 |            1 |
      ...
      +----------------------+-------------------+---------------------+-------------+--------------+
      
    4. Choose 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
      

      Pay attention to the format of the healthcheck-interval and healthcheck-timeout parameters: their values must be specified in Ns format.

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

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