Changing network load balancer settings
Note
You can only set the load balancer type (internal or external) when creating it and cannot change it later.
After you create a network load balancer, you can:
- Change the load balancer name and description.
- Change load balancer labels.
- Change the target group or its health check settings.
- Connect a target group.
- Add a listener.
Changing a load balancer name and description
- Navigate to the folder dashboard
and select Network Load Balancer. - Select a load balancer and click Edit at the top of the page.
- Enter a new name and description for the load balancer.
- Click Edit.
If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change the name and description of a load balancer:
-
Find out the ID or name of the load balancer by getting a list of network load balancers in the folder.
-
View the current
name
anddescription
of the load balancer:yc load-balancer network-load-balancer get <load_balancer_name_or_ID>
-
See the description of the CLI command for changing load balancer configuration:
yc load-balancer network-load-balancer update --help
-
Set a new name and description for the load balancer:
yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \ --new-name=<new_load_balancer_name> \ --description=<new_load_balancer_description>
-
Open the current Terraform configuration file that defines your infrastructure.
For more information about creating this file, see Creating a network load balancer.
For a complete list of editable network load balancer configuration fields, see this article
. -
In the network load balancer description, change the
name
anddescription
values:resource "yandex_lb_network_load_balancer" "foo" { name = "<load_balancer_name>" description = "<load_balancer_description>" ...
-
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validate
Terraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform plan
If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply
-
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
Use the update API method, providing the following in your request:
- Load balancer ID in the
networkLoadBalancerId
parameter. To find out the ID, get a list of network load balancers in the folder. - New name in the
name
parameter. - New description in the
description
parameter. - List of editable cluster configuration fields in the
updateMask
parameter (in this case,name
anddescription
).
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Changing load balancer labels
- Navigate to the folder dashboard
and select Network Load Balancer. - Select a load balancer and click Edit at the top of the page.
- Change the load balancer labels.
- Click Edit.
If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change the labels of a network load balancer:
-
View the current load balancer
labels
and their values:yc load-balancer network-load-balancer get <load_balancer_name_or_ID>
You can get the load balancer ID and name with the list of network load balancers in the folder.
-
See the description of the CLI command for changing load balancer configuration:
yc load-balancer network-load-balancer update --help
-
Set new values for the load balancer labels:
yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \ --labels <key_1>=<value_1>,<key_2>=<value_2>,...
-
Open the current Terraform configuration file that defines your infrastructure.
For more information about creating this file, see Creating a network load balancer.
For a complete list of editable network load balancer configuration fields, see this article
. -
In the network load balancer description, change the
name
anddescription
values:resource "yandex_lb_network_load_balancer" "foo" { ... labels = { <key_1> = "<value_1>" <key_2> = "<value_2>" ... } ...
-
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validate
Terraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform plan
If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply
-
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
Use the update API method, providing the following in your request:
- Load balancer ID in the
networkLoadBalancerId
parameter. To find out the ID, get a list of network load balancers in the folder. - New label values in the
labels
parameter. - List of editable cluster configuration fields in the
updateMask
parameter (in this case,labels
).
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Changing a target group or its health check settings
- Navigate to the folder dashboard
and select Network Load Balancer. - Select a load balancer and click Edit at the top of the page.
- Under Target groups, select a different target group from the drop-down list or create a new one.
- To change target group health check settings:
- In the section with the target group in question, click Configure.
- Specify new target group health check settings.
- Click Apply.
- Click Edit.
If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change a target group or its health check settings:
-
See the description of the CLI command for changing load balancer configuration:
yc load-balancer network-load-balancer update --help
-
Specify the target group's new ID and health check settings:
yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \ --target-group target-group-id=<target_group_ID>,` `healthcheck-name=<health_check_name>,` `healthcheck-interval=<health_check_interval>s,` `healthcheck-timeout=<response_timeout>s,` `healthcheck-unhealthythreshold=<number_of_failed_checks_to_get_Unhealthy_status>,` `healthcheck-healthythreshold=<number_of_successful_checks_to_get_Healthy_status>,` `healthcheck-tcp-port=<TCP_port>,` `healthcheck-http-port=<HTTP_port>,` `healthcheck-http-path=<URL>
Where:
-
--target-group
: Target group parameters and health check settings:-
target-group-id
: Target group ID.To find out the ID, get a list of target groups in the folder.
-
healthcheck-name
: Health check name. -
healthcheck-interval
: Health check interval in seconds. The possible values range from1s
to60s
. The interval must be at least 1 second longer than the response timeout. -
healthcheck-timeout
: Response timeout in seconds. The possible values range from1s
to60s
. -
healthcheck-unhealthythreshold
: Number of failed checks before traffic is no longer routed to the VM. The possible values range from2
to10
. -
healthcheck-healthythreshold
: Number of successful checks required to consider the VM ready to receive traffic. The possible values range from2
to10
. -
healthcheck-tcp-port
: Port for TCP health checks. The possible values range from1
to32,767
. -
healthcheck-http-port
: Port for HTTP health checks. The possible values range from1
to32,767
. -
healthcheck-http-path
: URL for HTTP health checks.
You cannot specify both
healthcheck-tcp-port
andhealthcheck-http-port
at the same time.Warning
Use the
<time_in_seconds>s
format, e.g.,20s
, for thehealthcheck-interval
andhealthcheck-timeout
values. -
You can get the load balancer ID and name with the list of network load balancers in the folder.
-
-
Open the current Terraform configuration file that defines your infrastructure.
For more information about creating this file, see Creating a network load balancer.
For a complete list of editable network load balancer configuration fields, see this article
. -
In the network load balancer description, change the target group ID and its health check settings under
attached_target_group
:resource "yandex_lb_network_load_balancer" "foo" { name = "<load_balancer_name>" ... attached_target_group { target_group_id = "<target_group_ID>" healthcheck { name = "<health_check_name>" http_options { port = <port_number> path = "<URL>" } } } ... }
Where:
name
: Name of the network load balancer.attached_target_group
: Description of the network load balancer's target group settings:-
target_group_id
: Target group ID.To find out the ID, get a list of target groups in the folder.
-
healthcheck
: Health check settings. Specify a name, a port number ranging from1
to32767
, and a path for health checks.
-
-
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validate
Terraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform plan
If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply
-
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
Use the update API method, providing the following in your request:
-
Load balancer ID in the
networkLoadBalancerId
parameter. To find out the ID, get a list of network load balancers in the folder. -
Target group ID and health check settings in the
attachedTargetGroups
parameter.To find out the ID, get a list of target groups in the folder.
-
List of editable cluster configuration fields in the
updateMask
parameter (in this case,attachedTargetGroups
).
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Attaching a target group
To attach a target group, follow this guide.
Adding a listener
To add a listener, follow this guide.