Create a load balancer
This guide shows you how to create a load balancer using the evroc CLI.
Creating a load balancer requires creating four types:
LoadBalancerL4RouteBackendServiceBackendPool
Create a backend pool
Create a backend pool by referencing the existing virtual machines you wish to place in the pool:
evroc loadbalancer backendpool create mybackendpool \
--backend-ref=myvm
Where the virtual machines are created by following the steps in Create a virtual machine.
--backend-ref can be specified multiple times to add multiple virtual machine to the backend pool.
Create a backend service
Create a backend service referencing the backend pool, and specifying which port the virtual machines in the backend pool should listen on:
evroc loadbalancer backendservice create mybackendservice \
--backend-pool-ref=mybackendpool \
--port=80
Additional CLI parameters
--proxy-protocol- Whether to enable proxy protocol for connections--ip-protocol-selection- Which backend IP address type to use. Valid values areIPv4andIPv6. Defaults toIPv4.
Create an L4 route
Create an L4 route referencing the backend service:
evroc loadbalancer l4route create myl4route \
--backend-service-ref=mybackendservice
Create the load balancer
Create a load balancer:
evroc loadbalancer loadbalancer create myloadbalancer \
--public-ip-ref=mypubip
Where the public IP is created by following the steps in Manage public IPs.
Attaching the load balancer to a specific VPC
By default, the load balancer is part of the default VPC and is deployed to every zone, attaching to the default subnet in each zone.
When creating a load balancer, you can specify which VPC and subnets it should be deployed to instead, using the
--vpc and --subnet parameters:
evroc loadbalancer loadbalancer create myloadbalancer \
--public-ip-ref=mypubip \
--vpc=myvpc \
--subnet=a:mysubnet-a \
--subnet=b:mysubnet-b
Where we have:
--vpc- The VPC the load balancer attaches to--subnet- A subnet to attach to in the formzone:subnet, wherezoneis one ofa,b, orc, and subnet is the subnet to attach to in that zone
--vpc and --subnet must be provided together. The load balancer will only deploy to zones for which a subnet has
been specified.
This configuration is immutable and cannot be modified once the load balancer has been created.
Add a listener to the load balancer
Add a listener to the load balancer referencing the L4 route:
evroc loadbalancer loadbalancer addlistener myloadbalancer \
--listener-name=mylistener \
--listener-port=80 \
--listener-route-ref=myl4route
--listener-route-ref can be specified multiple times to attach multiple routes to the listener.
Verify the load balancer
Check that the load balancer was created successfully:
evroc loadbalancer loadbalancer list
Or:
evroc loadbalancer loadbalancer get myloadbalancer
The load balancer is ready when the Ready status is True.