Attach a target group to a network load balancer
To attach a target group to a network load balancer:
- In the management console, select the folder where you wish to attach a target group to a load balancer.
- In the list of services, select Network Load Balancer.
- In the line of the load balancer to attach a target group to, click and select Attach target group.
- Select a target group or create a new one.
- Configure health check settings.
- 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.
-
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
-
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 | ... +----------------------+--------------------+-------------+----------+----------------+------------------------+----------+
-
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 | ... +----------------------+-------------------+---------------------+-------------+--------------+
-
Select 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
Mind the
healthcheck-interval
andhealthcheck-timeout
parameter format: the values must be inNs
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.