Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Network Load Balancer
  • Getting started
    • All tutorials
    • Architecture and protection of a basic internet service
    • Implementing fault-tolerant scenarios for NAT VMs
    • Configuring a fault-tolerant architecture in Yandex Cloud
    • Updating an instance group under load
    • Integrating Cloud DNS and a corporate DNS service
    • Connecting to Object Storage from Virtual Private Cloud
    • Connecting to Container Registry from Virtual Private Cloud
    • Implementing a secure high-availability network infrastructure with a dedicated DMZ based on the Check Point NGFW
    • Deploying Microsoft Exchange
    • Deploying an Always On availability group with an internal network load balancer
      • Overview
        • Overview
        • Management console
        • Terraform
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Service migration recommendations
  • Create an internal network load balancer for the NGINX Ingress controller
  • Create an infrastructure for the L7 load balancer
  • Test the L7 load balancer
  • Migrate user load from the external load balancer to the L7 load balancer
  • Keep public IP address for your service
  • Do not keep the public IP address for your service
  1. Tutorials
  2. Migrating services from an NLB load balancer to an ALB L7 load balancer for DDoS protection using Smart Web Security
  3. NLB load balancer as a target for an ALB
  4. Terraform

Migrating services from an external NLB load balancer to an L7 ALB load balancer with an internal NLB load balancer as a target using Terraform

Written by
Yandex Cloud
Updated at May 5, 2025
  • Service migration recommendations
  • Create an internal network load balancer for the NGINX Ingress controller
  • Create an infrastructure for the L7 load balancer
  • Test the L7 load balancer
  • Migrate user load from the external load balancer to the L7 load balancer
    • Keep public IP address for your service
    • Do not keep the public IP address for your service

To migrate a service from a network load balancer to an L7 load balancer:

  1. See recommendations for service migration.
  2. Create your infrastructure. At this step, you will connect your Smart Web Security profile to a virtual host of the L7 load balancer.
  3. Create an internal network load balancer for the NGINX Ingress controller.
  4. Test the L7 load balancer.
  5. Migrate the user load from the network load balancer to the L7 load balancer.

Service migration recommendationsService migration recommendations

  1. In addition to DDoS protection at OSI L7 using Yandex Smart Web Security, we recommend enabling DDoS protection at L3-L4. To do this, reserve a public static IP address with DDoS protection in advance and use this address for the L7 load balancer's listener.

    If the network load balancer's listener already uses a public IP address with DDoS protection, you can save it and use it for the L7 load balancer.

    If the network load balancer's listener uses a public IP address without DDoS protection, DDoS protection at L3-L4 when migrating to an L7 load balancer can only be achieved by changing the public IP for your service.

    When using L3-L4 DDoS protection, configure a trigger threshold for the L3-L4 protection mechanisms aligned with the amount of legitimate traffic to the protected resource. To set up this threshold, contact support.

    Also, set the MTU value to 1450 for the targets downstream of the load balancer. For more information, see Setting up MTU when enabling DDoS protection.

  2. We recommend performing migration during the hours when the user load is at its lowest. If you plan to keep your public IP address, bear in mind that migration involves moving this IP address from the load balancer to the L7 load balancer. Your service will be unavailable during this period. Under normal conditions, this may last for several minutes.

  3. When using an L7 load balancer, requests to backends come with the source IP address from the range of internal IP addresses of the subnets specified when creating the L7 load balancer. The original IP address of the request source (user) is specified in the X-Forwarded-For header. If you want to log public IP addresses of users on the web server, reconfigure it.

  4. See the autoscaling and resource units in the L7 load balancer.

Create an internal network load balancer for the NGINX Ingress controllerCreate an internal network load balancer for the NGINX Ingress controller

  1. Create an internal network load balancer for the NGINX Ingress controller. Select an option that agrees with the method you initially used to deploy your NGINX Ingress controller:

    Using a Helm chart
    Using a manifest
    1. Add the configuration parameters for the internal network load balancer to the values.yaml file you used to initially configure the NGINX Ingress controller. Leave the other parameters in the file unchanged.

      controller:
        service:
          external:
            enabled: true
          internal:
            enabled: true
            annotations:
              yandex.cloud/load-balancer-type: internal
              yandex.cloud/subnet-id: <subnet_ID_for_internal_network_load_balancer_IP_address>
            loadBalancerIP: <IP_address_of_internal_network_load_balancer_listener>
            externalTrafficPolicy: Local
      
    2. Use this command to apply the NGINX Ingress controller configuration changes:

      helm upgrade <NGINX_Ingress_controller_name> -f values.yaml <chart_for_NGINX_Ingress_controller> -n <namespace>
      
    1. Create a YAML file and describe the Service resource in it:

      apiVersion: v1
      kind: Service
      metadata:
        name: <resource_name>
        namespace: <namespace>
        annotations:
          yandex.cloud/load-balancer-type: internal
          yandex.cloud/subnet-id: <subnet_ID_for_internal_network_load_balancer_IP_address>
      spec:
        type: LoadBalancer
        externalTrafficPolicy: Local
        loadBalancerIP: <IP_address_of_internal_network_load_balancer_listener>
        ports:
        - port: <HTTP_port_number_e.g._80>
          targetPort: <HTTP_port_number_of_NGINX_Ingress_controller_pod_e.g._80>
          protocol: TCP
          name: http
        - port: <HTTPS_port_number_e.g._443>
          targetPort: <HTTPS_port_number_of_NGINX_Ingress_controller_pod_e.g._443>
          protocol: TCP
          name: https
        selector:
          <NGINX_Ingress_controller_pod_selectors>
      
    2. Apply the changes using this command:

    kubectl apply -f <Service_resource_file>
    
  2. Wait until the internal network load balancer is created and a matching Service object appears. You can use this command to view information about the services:

    kubectl get service
    

Create an infrastructure for the L7 load balancerCreate an infrastructure for the L7 load balancer

  1. If you do not have Terraform yet, install it.

  2. Get the authentication credentials. You can add them to environment variables or specify them later in the provider configuration file.

  3. Configure and initialize a provider. There is no need to create a provider configuration file manually, you can download it.

  4. Place the configuration file in a separate working directory and specify the parameter values. If you did not add the authentication credentials to environment variables, specify them in the configuration file.

  5. Download a configuration file to the same working directory based on the protocol you are using:

    • HTTP: alb-int-nlb-http.tf configuration file.
    • HTTPS: alb-int-nlb-https.tf configuration file.

    These files describe:

    • Subnets for the L7 load balancer.
    • Security group for the L7 load balancer.
    • Static address for the L7 load balancer.
    • Importing a TLS certificate to Certificate Manager (if HTTPS is used).
    • Smart Web Security security profile.
    • Target group, backend group, and HTTP router for the L7 load balancer.
    • L7-balancer.
  6. In the configuration file, set the following custom properties:

    1. Specify the values for the variables:

      • domain_name: Your service domain name.
      • network_id: ID of the network containing the VMs from the network load balancer's target group.
      • ip_address_int_nlb: Internal IP address of the internal load balancer you created earlier.
      • certificate (for HTTPS): Path to the self-signed custom certificate.
      • private_key (for HTTPS): Path to the private key file.
  7. Make sure the Terraform configuration files are correct using this command:

    terraform validate
    

    If there are any errors in the configuration files, Terraform will point them out.

  8. Create the required infrastructure:

    1. 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.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

    All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console.

  9. Specify the autoscaling settings in the L7 load balancer:

    1. In the management console, select the folder where you created the L7 load balancer.
    2. Select Application Load Balancer.
    3. Click the name of the load balancer in question.
    4. Click and select Edit.
    5. Under Autoscaling settings, set a limit on the number of resource units.

Test the L7 load balancerTest the L7 load balancer

  1. Wait until the L7 load balancer goes Active.

  2. Go to the new L7 load balancer and select Health checks on the left. Make sure you get HEALTHY for all the L7 load balancer's health checks.

  3. Run a test request to the service through the L7 load balancer, for example, using one of these methods:

    • Add this record to the hosts file on your workstation: <L7_load_balancer_public_IP_address> <service_domain_name>. Delete the record after the test.

    • Execute the request using cURL depending on the protocol type:

      curl http://<service_domain_name> \
          --resolve <service_domain_name>:<service_port>:<public_IP_address_of_L7_load_balancer>
      
      curl https://<service_domain_name> \
          --resolve <service_domain_name>:<service_port>:<public_IP_address_of_L7_load_balancer>
      

Migrate user load from the external load balancer to the L7 load balancerMigrate user load from the external load balancer to the L7 load balancer

Select one of the migration options:

  • Keep the public IP address for your service.
  • Do not keep public IP address for your service.

Keep public IP address for your serviceKeep public IP address for your service

  1. If your external network load balancer is using a dynamic public IP address, convert it to a static one.

  2. Delete the external network load balancer. Select an option that agrees with the method you initially used to deploy your NGINX Ingress controller:

    Using a Helm chart
    Using a manifest
    1. In the values.yaml file you used to initially configure the NGINX Ingress controller, under controller.service.external, set enabled: false. Leave the other parameters in the file unchanged.

      controller:
        service:
          external:
            enabled: false
          ...
      
    2. Use this command to apply the NGINX Ingress controller configuration changes:

      helm upgrade <NGINX_Ingress_controller_name> -f values.yaml <chart_for_NGINX_Ingress_controller> -n <namespace>
      

    Delete the Service resource for the external network load balancer using this command:

    kubectl delete service <Service_resource_name_for_external_network_load_balancer>
    
  3. Wait until the external network load balancer for NGINX Ingress controller and its respective Service object are deleted. You can use this command to view information about the services:

    kubectl get service
    

    This will make your service unavailable through the external network load balancer.

  4. In the L7 load balancer, assign to the listener the public IP address previously assigned to the external network load balancer.

    1. Open the configuration file you used to create the L7 load balancer (alb-int-nlb-http.tf or alb-int-nlb-https.tf).

    2. In the load balancer description, change the address parameter value under listener.endpoint.address.external_ipv4_address:

      resource "yandex_alb_load_balancer" "<load_balancer_name>" {
        ...
        listener {
          ...
          endpoint {
            address {
              external_ipv4_address {
                address = <service_public_IP_address>
              }
            }
            ports = [ <service_port> ]
          }
        }
      }
      

      Where address is the public IP address previously used by the network load balancer.

    3. Apply the changes:

      1. In the terminal, change to the folder where you edited the configuration file.

      2. Make sure the configuration file is correct using the command:

        terraform validate
        

        If the configuration is correct, the following message is returned:

        Success! The configuration is valid.
        
      3. Run the command:

        terraform plan
        

        The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.

      4. Apply the configuration changes:

        terraform apply
        
      5. Confirm the changes: type yes in the terminal and press Enter.

  5. After the IP addresses changes, your service will again be available through the L7 load balancer. Monitor the L7 load balancer's user load from the load balancer statistics charts.

  6. Delete the now free static public IP address you selected when creating the L7 load balancer.

    1. Open the configuration file you used to create the L7 load balancer (alb-int-nlb-http.tf or alb-int-nlb-https.tf).

    2. Delete the yandex_vpc_address resource description from the file:

      resource "yandex_vpc_address" "static-address" {
        description = "Static public IP address for the Application Load Balancer"
        name        = "alb-static-address"
        external_ipv4_address {
          zone_id                  = "ru-central1-a"
          ddos_protection_provider = "qrator"
        }
      }
      
    3. Apply the changes:

      1. In the terminal, change to the folder where you edited the configuration file.

      2. Make sure the configuration file is correct using the command:

        terraform validate
        

        If the configuration is correct, the following message is returned:

        Success! The configuration is valid.
        
      3. Run the command:

        terraform plan
        

        The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.

      4. Apply the configuration changes:

        terraform apply
        
      5. Confirm the changes: type yes in the terminal and press Enter.

Do not keep the public IP address for your serviceDo not keep the public IP address for your service

  1. To migrate user load from an external network load balancer to an L7 load balancer, in the DNS service of your domain's public zone, change the A record value for the service domain name to the public IP address of the L7 load balancer. If the public domain zone was created in Yandex Cloud DNS, change the record using this guide.

    Note

    The propagation of DNS record updates depends on the time-to-live (TTL) value and the number of links in the DNS request chain. This process can take a long time.

  2. As the DNS record updates propagate, follow the increase of requests to the L7 load balancer from the load balancer statistics charts.

  3. Follow the decrease of the external network load balancer load using the processed_bytes and processed_packets load balancer metrics. You can also create a dashboard to visualize these metrics. The absence of load on the external network load balancer for a prolonged period of time indicates that the user load has been transfered to the L7 load balancer.

  4. (Optional) Delete the external network load balancer after migrating user load to the L7 load balancer. Select an option that agrees with the method you initially used to deploy your NGINX Ingress controller:

    Using a Helm chart
    Using a manifest
    1. In the values.yaml file you used to initially configure the NGINX Ingress controller, under controller.service.external, set enabled: false. Leave the other parameters in the file unchanged.

      controller:
        service:
          external:
            enabled: false
          ...
      
    2. Use this command to apply the NGINX Ingress controller configuration changes:

      helm upgrade <NGINX_Ingress_controller_name> -f values.yaml <chart_for_NGINX_Ingress_controller> -n <namespace>
      

    Warning

    When you make changes to the NGINX Ingress controller configuration, your service will be temporarily unavailable.

    Delete the Service resource for the external network load balancer using this command:

    kubectl delete service <Service_resource_name_for_external_network_load_balancer>
    
  5. Wait until the external network load balancer for NGINX Ingress controller and its respective Service object are deleted. You can use this command to view information about the services:

    kubectl get service
    

Was the article helpful?

Previous
Management console
Next
Overview
© 2025 Direct Cursus Technology L.L.C.