Skip to main content
Version: v1.1.0

Stateless-lb

Description

The load balancer is using a user space Maglev implementation to load balance traffic among multiple targets.

At Start, the load balancer is subscribing to events from the NSP Service to get notifications about target registration / unregistration in order to update the identifiers in the nfqueue-loadbalancer program, the IP rules and the IP routes.

Since the nfqueue-loadbalancer program is running in user space, iptables together with nfqueue are used to bring traffic from kernel space to user space. The nfqueue-loadbalancer program will then add a forwarding mark on the traffic based on Maglev and according to the registered target identifiers, and will return the traffic to the kernel space. Using the forwarding mark, IP rules and IP routes, the traffic will be forwarded to the selected target.

The information whether the load balancer is capable of forwarding traffic towards at least one target is made available for the collocated frontend to retrieve and use for controlling traffic attraction.

Configuration

https://github.com/Nordix/Meridio/blob/master/cmd/load-balancer/config.go

Environment variableTypeDescriptionDefault
NSM_NAMEstringName of the podload-balancer
NSM_SERVICE_NAMEstringName of providing serviceload-balancer
NSM_CONNECT_TOurl.URLurl to connect to NSMunix:///var/lib/networkservicemesh/nsm.io.sock
NSM_DIAL_TIMEOUTtime.Durationtimeout to dial NSMgr5s
NSM_REQUEST_TIMEOUTtime.Durationtimeout to request NSE15s
NSM_MAX_TOKEN_LIFETIMEtime.Durationmaximum lifetime of tokens24h
NSM_NSP_SERVICEstringIP (or domain) and port of the NSP Servicensp-service:7778
NSM_CONDUIT_NAMEstringName of the conduitload-balancer
NSM_TRENCH_NAMEstringTrench the pod is running ondefault
NSM_LOG_LEVELstringLog levelDEBUG
NSM_NFQUEUEstringnetfilter queue(s) to be used by nfqlb0:3
NSM_NFQUEUE_FANOUTboolenable fanout nfqueue optionfalse
NSM_IDENTIFIER_OFFSET_STARTintEach Stream will get a unique identifier range starting from that value5000
NSM_GRPC_KEEPALIVE_TIMEtime.DurationgRPC keepalive timeout30s
NSM_GRPC_PROBE_RPC_TIMEOUTtime.DurationRPC timeout of internal gRPC health probe1s
NSM_GRPC_MAX_BACKOFFtime.DurationUpper bound on gRPC connection backoff delay5s
NSM_METRICS_ENABLEDboolEnable the metrics collectionfalse
NSM_METRICS_PORTintSpecify the port used to expose the metrics2223
NSM_SOCKETurl.URLServer socket to host Stream Availability Serviceunix:///var/lib/meridio/lb.sock

Command Line

CommandActionDefault
--helpDisplay a help describing
--versionDisplay the version

Communication

Here are all components the stateless-lb is communicating with:

ComponentSecuredMethodDescription
SpireTBDUnix SocketObtain and validate SVIDs
NSMyes (mTLS)Unix SocketRegister NSE
NSP Serviceyes (mTLS)TCPWatch configuration. Watch target registry.
FEyes (mTLS)Unix SocketSend internal connectivity information.

An overview of the communications between all components is available here.

Health check

The health check is provided by the GRPC Health Checking Protocol. The status returned can be UNKNOWN, SERVING, NOT_SERVING or SERVICE_UNKNOWN.

ServiceDescription
LivenessA unique service to be used by liveness probe to return status, can aggregate other lesser services
ReadinessA unique service to be used by readiness probe to return status, can aggregate other lesser services
ServiceProbeDescription
NSPCliReadinessMonitor status of the connection to the NSP service
NSMEndpointReadiness,LivenessMonitor status of the NSE
EgressReadinessMonitor the frontend availability
StreamReadinessCheck if at least 1 stream is serving
FlowReadinessCheck if at least 1 flow is serving

Privileges

To work properly, here are the privileges required by the stateless-lb:

NameDescription
Sysctl: net.ipv4.conf.all.forwarding=1Enable IP forwarding
Sysctl: net.ipv6.conf.all.forwarding=1Enable IP forwarding
Sysctl: net.ipv4.fib_multipath_hash_policy=1To use Layer 4 hash policy for ECMP on IPv4
Sysctl: net.ipv6.fib_multipath_hash_policy=1To use Layer 4 hash policy for ECMP on IPv6
Sysctl: net.ipv4.conf.all.rp_filter=0Allow packets to have a source IPv4 address which does not correspond to any routing destination address.
Sysctl: net.ipv4.conf.default.rp_filter=0Allow packets to have a source IPv6 address which does not correspond to any routing destination address.
Sysctl: net.ipv4.fwmark_reflect=1Allow LB generated outbound ICMP Frag Needed reply to use VIP as source address.
Sysctl: net.ipv6.fwmark_reflect=1Allow LB generated outbound ICMPv6 Packet Too Big reply to use VIP as source address.
NET_ADMINThe load balancer configures IP rules and IP routes to steer packets (processed by nfqueue-loadbalancer program) to targets. The user space load balancer program relies on libnetfilter_queue.
IPC_LOCKThe user space load balancer program uses shared memory.
IPC_OWNERThe user space load balancer program uses shared memory.