Changing network load balancer settings
Note
You can only set the load balancer type (internal or external) when creating it. You cannot update its type afterwards.
After you create a network load balancer, you can:
Changing a load balancer's name and description
- Go to the folder page
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 command line interface yet, install and initialize 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.
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>
-
View a description of the update load balancer configuration CLI command:
yc load-balancer network-load-balancer update --help
-
Enter 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 with an infrastructure plan.
For more information about creating this file, see Creating a network load balancer.
For a complete list of updatable configuration fields of a network load balancer, see the provider documentation
. -
In the network load balancer description, change the
name
anddescription
parameter values:resource "yandex_lb_network_load_balancer" "foo" { name = "<load_balancer_name>" description = "<load_balancer_description>" ...
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
Use the update API method and include the following in the request:
- Load balancer ID in the
networkLoadBalancerId
parameter. To find out the ID, get a list of network load balancers in the folder. - A new name in the
name
parameter. - A new description in the
description
parameter. - List of cluster configuration fields to update 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
- Go to the folder page
and select Network Load Balancer. - Select a load balancer and click Edit at the top of the page.
- Change load balancer labels.
- Click Edit.
If you do not have the Yandex Cloud command line interface yet, install and initialize 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.
To update the labels of a network load balancer:
-
View the current load balancer's
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 a list of network load balancers in the folder.
-
View a description of the update load balancer configuration CLI command:
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 with an infrastructure plan.
For more information about creating this file, see Creating a network load balancer.
For a complete list of updatable configuration fields of a network load balancer, see the provider documentation
. -
In the network load balancer description, change the
name
anddescription
parameter values:resource "yandex_lb_network_load_balancer" "foo" { ... labels = { <key_1> = "<value_1>" <key_2> = "<value_2>" ... } ...
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
Use the update API method and include the following in the 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 cluster configuration fields to update 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
- Go to the folder page
and select Network Load Balancer. - Select a load balancer and click Edit at the top of the page.
- Under Target groups, select a new target group from the drop-down list or create a new one.
- To change target group health check settings:
- In the section of the appropriate target group, click Configure.
- Set up new target group health check parameters.
- Click Apply.
- Click Edit.
If you do not have the Yandex Cloud command line interface yet, install and initialize 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.
To update a target group or its health check settings:
-
View a description of the update load balancer configuration CLI command:
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_health_checks_for_Unhealthy_status>,` `healthcheck-healthythreshold=<number_of_successful_health_checks_for_Healthy_status>,` `healthcheck-tcp-port=<TCP_port>,` `healthcheck-http-port=<HTTP_port>,` `healthcheck-http-path=<URL>
Where:
-
--target-group
: Target group parameters and settings of its resource health checks:-
target-group-id
: Target group ID.To find out the ID, get a list of target groups in the folder.
-
healthcheck-name
: Resource health check name. -
healthcheck-interval
: Health check interval in seconds. The possible values are from1s
to60s
. The interval must be at least 1 second longer than the waiting time. -
healthcheck-timeout
: Response timeout in seconds. The possible values are from1s
to60s
. -
healthcheck-unhealthythreshold
: Number of failed checks after which no traffic will be routed to a virtual machine. The possible values are from2
to10
. -
healthcheck-healthythreshold
: Number of successful checks required to consider a virtual machine ready to receive traffic. The possible values are from2
to10
. -
healthcheck-tcp-port
: Port for health checks via TCP. The possible values are from1
to32,767
. -
healthcheck-http-port
: Port for health checks via HTTP. The possible values are from1
to32,767
. -
healthcheck-http-path
: URL to perform health checks via HTTP.
You cannot specify
healthcheck-tcp-port
andhealthcheck-http-port
at the same time.Warning
The
healthcheck-interval
andhealthcheck-timeout
parameter values must be in<time_in_seconds>s
format, e.g.,20s
. -
You can get the load balancer ID and name with a list of network load balancers in the folder.
-
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating a network load balancer.
For a complete list of updatable configuration fields of a network load balancer, see the provider documentation
. -
In the network load balancer description, update 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 parameters:-
target_group_id
: Target group ID.To find out the ID, get a list of target groups in the folder.
-
healthcheck
: Health check parameters. Enter a name, a port number ranging from1
to32767
, and a path for health checks.
-
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
Use the update API method and include the following in the 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 its health check settings in the
attachedTargetGroups
parameter.To find out the ID, get a list of target groups in the folder.
-
List of cluster configuration fields to update 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.