Attach a target group to a network load balancer
To attach a target group to a network load balancer:
- Open the Load Balancer section in the folder where you want to attach the target group to the load balancer.
- Click in the row of that load balancer. If you already have a target group created, select it. If not, create one.
- Configure health check settings.
- 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.
-
See the description of the CLI's attach target group command to a network load balancer:
$ yc load-balancer network-load-balancer attach-target-group --help
-
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 | ... +----------------------+--------------------+-------------+----------+----------------+------------------------+----------+
-
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 | ... +----------------------+-------------------+---------------------+-------------+--------------+
-
Choose the
ID
orNAME
of the required load balancer and target group. -
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
andhealthcheck-timeout
parameters: their values must be specified inNs
format.For more information about check parameters, see the section Resource health check.
You can attach a target group to a network load balancer using the attachTargetGroup API method.