Skip to main content

Connect a load balancer

Last update:
  1. Create a global router.

  2. Connect networks and subnets to the global router for each VLAN and Cloud platform project where the servers for balancing are located.

    For Cloud powered by VMware, networks and subnets can only be added through technical support.

  3. Assign IP addresses from the subnets to the servers.

  4. Configure routing to the load balancer subnet.

  5. Order a load balancer.

  6. Verify load balancer operation.

1. Create a global router

  1. In the Control panel, in the top menu, click Products and select Global Router.
  2. Click Create router. A limit of five global routers is set for each account.
  3. Enter the router name.
  4. Click Create.
  5. If the router was created with the status ERROR or is stuck in one of the statuses, create a ticket.

2. Connect networks and subnets to the global router⁠

carefully

When creating a network, do not use addresses from the 10.128.0.0/16 subnet on your servers. This subnet hosts load balancers, and using it may cause load balancer malfunctions.

Use for a dedicated or hosted server.

You can connect a new or existing network to the router if it is not already connected to any of the account's global routers.

  1. In the control panel, on the top menu, click Products and select Global Router.

  2. Go to the router page → Networks tab.

  3. Click Create network.

  4. Enter a network name. It will only be used in the control panel.

  5. Select the Servers and Equipment service.

  6. Select a location for the network.

  7. Select or enter a VLAN.

  8. If you want to create a network up to an internal segment (Q-in-Q), specify its tag—a number from 2 to 4094. If a network already exists for the VLAN, you must specify the Q-in-Q segment of this VLAN.

  9. Enter a subnet name. It will only be used in the control panel.

  10. Enter the CIDR—the IP address and mask of the private subnet. You can enter a new subnet or an existing private server subnet if it has not yet been added to any of the global routers in the account. The subnet must meet the following conditions:

    • belong to the RFC 1918 private address range: 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16;
    • have a size of at least /29, as three addresses will be occupied by Selectel network equipment;
    • do not overlap with other subnets added to this router—IP addresses must not repeat across subnets on the same router;
    • if a Managed Kubernetes cluster on cloud servers is included in the global router network, the subnet must not overlap with the ranges 10.10.0.0/16, 10.96.0.0/12, 10.250.0.0/16 and 10.251.0.0/24. If a cluster on dedicated servers is included in the network — with ranges 10.10.0.0/16, 10.222.0.0/16, 10.250.0.0/16, 10.251.0.0/24 and 172.250.0.0/14. These subnets are used for Managed Kubernetes internal addressing, and their use may lead to conflicts in the global router network.
  11. Enter the gateway IP or leave the first address from the subnet that is assigned by default. Do not assign this address to your devices to avoid network disruption.

  12. Enter the service IPs or leave the last addresses from the subnet that are assigned by default. Do not assign these addresses to your devices to avoid network disruption.

  13. Click Create network.

  14. Optional: check the network topology on the global router. In the Control panel, in the top menu, click ProductsGlobal Router → router page → Network map.

  15. If you specified a Q-in-Q tag in step 8, you need to enable Q-in-Q technology on the switch port and configure the private network interface that you specified in step 10. Learn more in the Configure Q-in-Q section of the Q-in-Q guide.

3. Assign IP addresses to servers

  1. Connect to the server via SSH or via KVM console.

  2. Open the netplan utility configuration file with the vi:

    vi /etc/netplan/01-netcfg.yaml
  3. Add or change the values of the private network interface settings:

    <eth_name>:
    addresses: [<ip_address>]

    Specify:

    • <eth_name> — the name of the private network interface;
    • <ip_address> — the private IP address of the server with a subnet mask, for example 192.168.0.2/24.
  4. Press ESC.

  5. Exit the vi text editor with your changes saved:

    :wq
  6. Apply the configuration:

    netplan apply
  7. Optional: reboot the server.

  8. Optional: assign a private IP address to the server in the control panel.

4. Configure routing to the load balancer subnet

On each server, you must pre-configure routing to the subnet where we will host the load balancer when the service is connected. By default, we host load balancers in the 10.128.0.0/16 subnet, but you can choose any suitable /16 subnet.

  1. Connect to the server.

  2. Open the network configuration file:

    vi /etc/netplan/01-netcfg.yaml
  3. At the end of the block containing the data for the required network interface, add the route:

    routes:
    - to: <ip_address>/<mask>
    via: <gateway>

    Specify:

    • <ip_address>/<mask> — the load balancer subnet. You can specify the 10.128.0.0/16 subnet, where we host load balancers by default, or any suitable /16;
    • <gateway> — the IP address from the server subnet that you designated as the gateway to the global router when connecting networks and subnets.
  4. Save the file.

  5. Check the settings:

    sudo netplan try
  6. Apply the changes:

    netplan apply

5. Order a load balancer

  1. If your servers use the HTTPS protocol, add your TLS(SSL) certificate to the Certificate Manager. You can also issue a Let's Encrypt® certificate.

  2. In the control panel, on the top menu, click Products and select Load Balancer.

  3. Click Connect a load balancer.

  4. Select a plan according to the required channel bandwidth — 20, 50, 100, or 1000 Mbps. If you need a different channel bandwidth, select Other and specify the required value in Mbps.

  5. Specify the global router to which you connected the networks and subnets — its name, identifier, or the list of subnets added to the router. Router details can be viewed in the control panel: in the top menu, click ProductsGlobal router → router page.

  6. Specify the load balancer subnet you entered when configuring routing on the servers.

  7. Select a balancing algorithm:

    • Round Robin — a round-robin algorithm where requests are passed to each server in turn;
    • Weighted Round Robin — a weighted round-robin algorithm where each server is assigned a weight coefficient corresponding to its performance and power. Servers with a higher coefficient receive more requests;
    • Source IP hash — an algorithm where the preferred server for receiving a request is selected depending on the HTTP header or IP address;
    • Least Connections — an algorithm where the request is sent to the least loaded server.
  8. If Sticky Sessions are required, select the Sticky Sessions checkbox.

  9. Select the target server protocol: TCP, HTTP, HTTPS.

  10. If you selected the TCP protocol, specify the parameters for using the protocol — all private IP addresses assigned within the global router networks, specifying the ports.

  11. If you selected the HTTP protocol, specify all combinations of URLs accepted from the Internet and the IP addresses to which they should be redirected, specifying the port. For example, http://domain.com/page — http://X.X.X.X:X.

  12. If you selected the HTTPS protocol, specify:

    • all combinations of URLs accepted from the Internet and the IP addresses to which they should be redirected, specifying the port. For example, https://domain.com/page — http://X.X.X.X:X;
    • The ID of the certificate added in step 1. You can view the ID in the control panel: in the top menu, click ProductsCertificate Manager → in the menu for the certificate, select Copy UUID;
    • The ID of the project where the certificate is located.
  13. Optional: if you need to provide any additional information, enter it in the Additional comment field. For example, describe the use case in more detail, specify in which pools the infrastructure is hosted, or leave administrator contact information for details.

  14. Click Connect a load balancer.

  15. We will create and send a ticket to connect the service. The connection process takes up to seven business days. Once the load balancer is ready, we will provide you with a protected public IP address in the ticket; you need to direct incoming traffic to this address for balancing.

6. Verify load balancer operation

To verify load balancer operation, send test requests to the IP address you received when ordering the load balancer.