Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Network Load Balancer
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Network load balancers
      • Create a network load balancer
      • Create an internal network load balancer
      • Start a load balancer
      • Stop a load balancer
      • Delete a load balancer
      • Check target health statuses
      • Add a listener
      • Delete a listener
    • Target groups
      • Create a target group
      • Attach a target group to a load balancer
      • Detach a target group from a load balancer
      • Delete a target group
  • Concepts
    • Network load balancer
    • Internal network load balancer
    • Listener
    • Targets and groups
    • Resource health checks
    • Quotas and limits
  • Best practices for using the service
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • NetworkLoadBalancerService
      • TargetGroupService
      • OperationService
    • REST
      • Overview
      • NetworkLoadBalancer
        • Overview
        • addListener
        • attachTargetGroup
        • create
        • delete
        • detachTargetGroup
        • get
        • getTargetStates
        • list
        • listOperations
        • removeListener
        • start
        • stop
        • update
      • TargetGroup
        • Overview
        • addTargets
        • create
        • delete
        • get
        • list
        • listOperations
        • removeTargets
        • update
      • Operation
        • Overview
        • get
  • Questions and answers
  1. Step-by-step instructions
  2. Network load balancers
  3. Create an internal network load balancer

Create an internal network load balancer

  • Examples
    • Creating an internal network load balancer without a listener
    • Creating an internal network load balancer with a listener and attached target group

The feature is at the Preview stage.

Note

The internal network load balancer's listener is assigned a random IP address from the range of addresses of the selected subnet.

CLI
API
Terraform

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.

  1. Before creating a load balancer, create a target group to attach to it.

  2. View a description of the CLI command to create a network load balancer:

    $ yc load-balancer network-load-balancer create --help
    
  3. To create an internal load balancer with a listener, run the following command:

    $ yc load-balancer network-load-balancer create \
    --name internal-lb-test \
    --type internal \
    --region-id ru-central1 \
    --listener name=test-listener,port=80,internal-subnet-id=<subnet ID>
    
  4. Get the list of all load balancers to make sure that the load balancer was created:

    $ yc load-balancer network-load-balancer list
    

You can create an internal network load balancer using the create API method.

With Terraform, you can quickly create a cloud infrastructure in Yandex.Cloud. The infrastructure components are identified through configuration files that specify the required cloud resources and their parameters.

If you don't have Terraform yet, install it and configure the Yandex.Cloud provider.

To create an internal network load balancer with a listener:

  1. In the configuration file, describe the parameters of resources that you want to create:

    • name: The name of the network load balancer.
    • type: The type of the network load balancer. Use internal to create an internal network load balancer.
    • listener: The listener parameters.
      • name: The name of the listener.
      • port: The port to receive traffic.
      • intenal_address_spec: The specification of the internal load balancer's listener.
        • subnet_id: The subnet ID.

    Example configuration file structure:

    provider "yandex" {
        token = "<OAuth or static key of service account>"
        folder_id = "<folder ID>"
        zone      = "ru-central1-a"
      }
    
    resource "yandex_lb_network_load_balancer" "internal-lb-test" {
      name = "internal-lb-test"
      type = "internal"
    
      listener {
        name = "my-listener"
        port = 8080
        internal_address_spec {
          subnet_id = "<Subnet ID>"
        }
      }
    

    For more information about the resources you can create using Terraform, see the provider documentation.

  2. Make sure that the configuration files are correct.

    1. In the command line, go to the directory where you created the configuration file.

    2. Run the check using the command:

      $ terraform plan
      

    If the configuration is described correctly, the terminal displays a list of created resources and their parameters. If there are errors in the configuration, Terraform points them out.

  3. Deploy the cloud resources.

    1. If the configuration doesn't contain any errors, run the command:

      $ terraform apply
      
    2. Confirm that you want to create the resources.

    Afterwards, all the necessary resources are created in the specified folder. You can check resource availability and their settings in management console.

Examples

Creating an internal network load balancer without a listener

CLI

To create an internal load balancer without a listener, run the command:

$ yc load-balancer network-load-balancer create \
--name internal-lb-test-1 \
--type internal \
--region-id ru-central1

Creating an internal network load balancer with a listener and attached target group

CLI
  1. To create an internal load balancer with a listener and immediately attach a target group to it, get the list of target groups:

    $ yc load-balancer target-group list
    +----------------------+------------------+---------------------+-------------+--------------+
    |          ID          |       NAME       |       CREATED       |  REGION ID  | TARGET COUNT |
    +----------------------+------------------+---------------------+-------------+--------------+
    | b7rv80bfibkph3ekqqle | test-internal-tg | 2020-08-09 07:49:18 | ru-central1 |            3 |
    +----------------------+------------------+---------------------+-------------+--------------+
    
  2. Run the command using the target group ID in the target-group-id parameter:

    $ load-balancer network-load-balancer create \
    --name internal-lb-test-3 \
    --type internal \
    --region-id ru-central1 \
    --listener name=test-listener,port=80,internal-subnet-id=e9b81t3kjmi0auoi0vpj \
    --target-group target-group-id=b7rv80bfibkph3ekqqle,healthcheck-name=http,healthcheck-interval=2s,healthcheck-timeout=1s,healthcheck-unhealthythreshold=2,healthcheck-healthythreshold=2,healthcheck-http-port=80
    

    Note the format of the healthcheck-interval and healthcheck-timeout parameters: specify their values as Ns, where N is the value in seconds.

Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC