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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Tutorials
    • All tutorials
    • Differentiation of access permissions for user groups
    • Creating an L7 load balancer with a Smart Web Security security profile through an Application Load Balancer Ingress controller
    • Centralized online publication and app protection against DDoS attacks
      • Overview
        • Overview
        • Management console
        • Terraform
    • Delivering logs from a VM instance to Cloud Logging
    • Storing load balancer logs to PostgreSQL
    • Secure storage of GitLab CI passwords as Yandex Lockbox secrets
    • Service account with an OS Login profile for VM management via Ansible
    • Transferring logs from Container Optimized Image to Cloud Logging
    • Adding an HTML page to work with SmartCaptcha
    • Creating an L7 load balancer with a security profile
    • Alert settings in Monitoring
    • Exporting audit logs to MaxPatrol SIEM
    • Exporting audit logs to SIEM Splunk systems
    • Uploading audit logs to ArcSight SIEM
    • Server-side encryption for an Object Storage bucket
    • Encrypting secrets in Hashicorp Terraform
    • Managing KMS keys with Hashicorp Terraform
    • Auto Unseal in Hashicorp Vault

In this article:

  • Service migration recommendations
  • Getting started
  • Create a Smart Web Security profile
  • Install an Application Load Balancer Ingress controller and create resources in your Managed Service for Kubernetes cluster
  • Migrate the user load from the network load balancer to the L7 load balancer
  • Keep the public IP address for your service
  • Do not keep the public IP address for your service
  1. Security
  2. Migrating services from an NLB to L7 ALB for DDoS protection using Smart Web Security
  3. NLB with a Managed Service for Kubernetes cluster as a target
  4. Management console

Migrating services from an NLB load balancer with a Yandex Managed Service for Kubernetes cluster as a target to an L7 ALB load balancer using the management console

Written by
Yandex Cloud
Updated at May 5, 2025
  • Service migration recommendations
  • Getting started
  • Create a Smart Web Security profile
  • Install an Application Load Balancer Ingress controller and create resources in your Managed Service for Kubernetes cluster
  • Migrate the user load from the network load balancer to the L7 load balancer
    • Keep the 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. Complete the prerequisite steps.
  3. Create a Smart Web Security profile.
  4. Install an Application Load Balancer Ingress controller and create resources in your Managed Service for Kubernetes cluster. At this step, you will connect your Smart Web Security profile to 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. For the L7 load balancer, two resource units will be created in each of the subnets specified when creating the Ingress resource. The Ingress resource annotations do not support specifying the minimum number of resource units for an L7 load balancer. A group of resource units is automatically scaled depending on the external load on load balancer nodes.

  5. The features of the Application Load Balancer load balancer may differ from those of your load balancer deployed in the Managed Service for Kubernetes cluster. See the Application Load Balancer Ingress controller description and operating principles.

Getting startedGetting started

  1. Create subnets in three availability zones. The L7 load balancer will use these subnets.

  2. Create security groups that allow the L7 load balancer to receive incoming traffic and send it to the targets and allow the targets to receive incoming traffic from the load balancer.

  3. When using HTTPS, add the TLS certificate of your servicec to Yandex Certificate Manager.

  4. Reserve a static public IP address with DDoS protection at level L3-L4 for the L7 load balancer. See service migration recommendations.

  5. The Managed Service for Kubernetes services used as backends must be of the NodePort type. If your services employ another type, change it to NodePort. For more details on this type, please see the Kubernetes documentation.

Create a Smart Web Security profileCreate a Smart Web Security profile

Create a Smart Web Security security profile by selecting From a preset template.

Use these settings when creating the profile:

  • In the Action for the default base rule field, select Allow.
  • For the Smart Protection rule, enable Only logging (dry run).

These settings are limited to logging the info about the traffic without applying any actions to it. This will reduce the risk of disconnecting users due to profile configuration issues. As you move along, you will be able to disable Only logging (dry run) and configure some prohibiting rules for your use case in the security profile.

Install an Application Load Balancer Ingress controller and create resources in your Managed Service for Kubernetes clusterInstall an Application Load Balancer Ingress controller and create resources in your Managed Service for Kubernetes cluster

  1. Install an Yandex Application Load Balancer Ingress controller.

  2. Create an IngressClass resource for the L7 load balancer's Ingress controller:

    1. Create a YAML file and describe the IngressClass resource in it.

      IngressClass resource example:

      apiVersion: networking.k8s.io/v1
      kind: IngressClass
      metadata:
        labels:
          app.kubernetes.io/component: controller
        name: ingress-alb
      spec:
        controller: ingress.alb.yc.io/yc-alb-ingress-controller
      
    2. Use the following command to create the IngressClass resource:

      kubectl apply -f <IngressClass_resource_file>
      
  3. Create an Ingress resource:

    1. Read the descriptions of the Ingress resource fields and annotations and see the example.

    2. Create a YAML file and describe the Ingress resource in it:

      • Complete the annotations section for the L7 load balancer settings:

        • ingress.alb.yc.io/subnets: IDs of the subnets in the three availability zones for the L7 load balancer nodes. Specify the IDs separated by commas with no spaces.

        • ingress.alb.yc.io/security-groups: ID of one or more security groups for the L7 load balancer. For multiple groups, specify their IDs separated by commas with no spaces.

        • ingress.alb.yc.io/external-ipv4-address: Previously reserved static public IP address.

        • ingress.alb.yc.io/group-name: Name of the Ingress resource group. Ingress resources are grouped together, each group served by a separate Application Load Balancer instance with a dedicated public IP address.

        • ingress.alb.yc.io/security-profile-id: ID of the previously created Smart Web Security security profile.

          Warning

          The security profile will be linked to the virtual host of the L7 load balancer. Specifying your security profile is the key step to connecting Smart Web Security.

        • ingress.alb.yc.io/autoscale-min-zone-size: Minimum number of resource units per availability zone, based on expected load.

          We recommend selecting the number of resource units based on the load expressed in:

          • Number of requests per second (RPS)
          • Number of concurrent active connections
          • Number of new connections per second
          • Traffic processed per second
      • For the ingressClassName field, enter the name of the IngressClass resource you created earlier.

      • When using HTTPS, complete the tls section:

        • hosts: Your service domain name the TLS certificate corresponds to.
        • secretName: TLS certificate of your service in Yandex Certificate Manager, in yc-certmgr-cert-id-<certificate_ID> format.
      • Complete the rules section in line with your rules for distribution of incoming traffic among backends depending on the domain name (host field) and requested resource (http.paths field).

        • host: Your service domain name.

        • pathType: Type of reference to the requested resource:

          • Exact: Request URI path must match the path field value.
          • Prefix: Request URI path must start with the path field value.
        • path: Incoming request URI path (if Exact) or its prefix (if Prefix).

        • backend: Reference to a backend or group of backends to process the requests with the specified domain name and URI path. Specify either a service backend (service) or a backend group (resource) but not both.

          • service: Managed Service for Kubernetes backend service for processing requests:

            • name: Managed Service for Kubernetes service name. The Service resource this field refers to must be described in line with this configuration.
            • port: Service port Ingress is going to address. For the service port, specify either a number (number) or a name (name) but not both.

            Warning

            The Managed Service for Kubernetes services used as backends must be of the NodePort type.

          • resource: Reference to the HttpBackendGroup group of backends to process the requests. A backend group can route traffic to either Managed Service for Kubernetes services or Yandex Object Storage buckets. When using a backend group, advanced Application Load Balancer functionality is available. You can also specify relative backend weights to allocate traffic to them in proportion.

            • kind: HttpBackendGroup
            • name: Backend group name. The name must match the value specified in the metadata.name field of the HttpBackendGroup resource. The HttpBackendGroup resource this field refers to must be described in line with this configuration.
            • apiGroup: alb.yc.io

      Ingress resource example:

      apiVersion: networking.k8s.io/v1
      kind: Ingress
      metadata:
        name: <resource_name>
        annotations:
          ingress.alb.yc.io/subnets: <ru-central1-a_subnet_ID,ru-central1-b_subnet_ID,ru-central1-d_subnet_ID>
          ingress.alb.yc.io/security-groups: <L7_load_balancer_security_group_ID>
          ingress.alb.yc.io/external-ipv4-address: <static_public_IP_address>
          ingress.alb.yc.io/group-name: <resource_group_name>
          ingress.alb.yc.io/security-profile-id: <Smart_Web_Security_security_profile_ID>
          ingress.alb.yc.io/autoscale-min-zone-size: <minimum_number_of_L7_load_balancer_resource_units_per_zone>
      spec:
        ingressClassName: <IngressClass_resource_name>
        tls:
          - hosts:
              - <service_domain_name>
            secretName: yc-certmgr-cert-id-<certificate_ID>
        rules:
          - host: <service_domain_name>
            http:
              paths:
              - path: /
                pathType: Prefix
                backend:
                  service:
                    name: <Kubernetes_service_name>
                    port:
                      number: <port_number_e.g._443>
      
    3. Use the following command to create the Ingress resource:

      kubectl apply -f <Ingress_resource_file>
      
  4. An L7 load balancer will be deployed based on the Ingress resource configuration. Wait until its creation is complete and Ingress has a public IP address linked. You will need this IP address to check requests. You can view resource info using this command:

    kubectl get ingress <Ingress_resource_name> -w
    
  1. 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 the user load from the network load balancer to the L7 load balancerMigrate the user load from the network 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 the public IP address for your serviceKeep the public IP address for your service

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

  2. Delete all listeners in the network load balancer to release the static public IP address. This will make your service unavailable through the network load balancer.

  3. In the L7 load balancer, assign to the listener the public IP address previously used by the network load balancer:

    1. Open the YAML file that describes the Ingress resource.

    2. Under annotations, for the ingress.alb.yc.io/external-ipv4-address field, specify the public IP address previously assigned to the network load balancer.

    3. Apply changes using this command:

      kubectl apply -f <Ingress_resource_file>
      
  4. Wait for the Ingress resource to finish changing its public IP address. You can view resource information using this command:

    kubectl get ingress <Ingress_resource_name> -w
    

    After the IP address changes, your service will again be available through the L7 load balancer.

  5. Go to the L7 load balancer:

    1. In the management console, go to the folder the Managed Service for Kubernetes cluster is in.
    2. Select Managed Service for Kubernetes.
    3. Select the cluster.
    4. Select Network on the left, and the Ingress tab on the right. For your Ingress resource, follow the L7 load balancer link in the Load balancer column.
    5. Monitor the L7 load balancer user load in the load balancer statistics charts.
  6. Delete the released static public IP address previously reserved for the L7 load balancer.

  7. Optionally, delete the network load balancer after migrating user load to the L7 load balancer.

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 a 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, monitor the increase of requests coming to the L7 load balancer:

    1. In the management console, go to the folder the Managed Service for Kubernetes cluster is in.
    2. Select Managed Service for Kubernetes.
    3. Select the cluster.
    4. Select Network on the left, and the Ingress tab on the right. For your Ingress resource, follow the L7 load balancer link in the Load balancer column.
    5. Monitor the L7 load balancer's user load from the load balancer statistics charts.
  3. You can monitor the decrease of the network load balancer load using the processed_bytes and processed_packets load balancer metrics. You can create a dashboard to visualize these metrics. The absence of load on the network load balancer for a prolonged period of time indicates that the user load has been transferred to the L7 load balancer.

  4. (Optional) Delete the network load balancer after migrating the user load to the L7 load balancer.

Was the article helpful?

Previous
Overview
Next
Terraform
Yandex project
© 2025 Yandex.Cloud LLC