cue

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2024 License: GPL-2.0 Imports: 6 Imported by: 0

README

Cue

A library to manage load balanced services. A balancer implementation uses the Director --- configured with a list of services which include health check definitions --- to monitor backed servers and notify when state has changed. The balancer can then update the data-plane to reflect the backend availability status.

A BGP implementation is included and may be used to advertise healthy virtual IP address to the network. Multiprotocol extensions for IPv6 are now supported.

Primarily this is used in the vc5 load balancer and is subject to some change.

Documentation

Documentation is here.

Command line utilities

A utility for testing the BGP implementation is in the cmd/ directory. This can be used to bring up a session over IPv4 or IPv6 and advertise addresses to a peer with various options for setting BGP path attributes, filtering exported IP addresses with prefixes.

Example invocations are listed in comments in the code.

Loopback BGP

I have found that it is possible to connect to a local BIRD instance and advertise addresses for re-distribution into the network from there. Here I connect to BIRD using multiprotocol extensions on the loopback interface with 127.0.0.1 as my router ID and the loopback IP addresses for both IPv4 and IPv6 next hop (BIRD will update these when re-advertising):

go run bgp.go -6 ::1 -m 65001 127.0.0.1 127.0.0.1

Using the BIRD configuration below I can then connect to a router and gain the benefits of using BFD. Global IPv6 addresses on the local server and the router are needed for the IPv6 address to be re-advertised successfully.

log syslog all;
protocol device {}
protocol bfd {}

filter vips {
    if net ~ [ 192.168.101.0/24{32,32} ] then accept; # accept /32 prefixes from 192.168.101.0/24
    if net ~ [ fd0b:2b0b:a7b8:1ee7:c0de::/80{128,128} ] then accept; # similar config for IPv6
    reject;
}

protocol bgp core {
    local    as 65001;
    neighbor as 65000;
    neighbor 10.12.34.56;
    ipv4 { export filter vips; import none; next hop self; };
    ipv6 { export filter vips; import none; next hop self; };
    bfd on;
}

protocol bgp lb {
    local    as 65001;  # iBGP - we could use eBGP if we specify 'multihop':
    neighbor as 65001;  # loopback address doesn't count as "directly connected"
    neighbor 127.0.0.1; # load balancer connects on the loopback interface
    passive;            # load balancer always inititates the connection
    ipv4 { export none; import all; };
    ipv6 { export none;	import all; };
}

If you get it working on other implementations then it would be great to have more sample configurations here.

Documentation

Index

Constants

View Source
const (
	TCP = 0x06
	UDP = 0x11
)

Variables

This section is empty.

Functions

func AllVIPs

func AllVIPs(services []Service) (r []netip.Addr)

func HealthyVIPs

func HealthyVIPs(services []Service) (r []netip.Addr)

Types

type Check

type Check = mon.Check

type Destination

type Destination struct {
	Address  netip.Addr  `json:"address"`
	Port     uint16      `json:"port"`
	Disabled bool        `json:"disabled"`
	Weight   uint8       `json:"weight"`
	Status   mon.Status  `json:"status"`
	Checks   []mon.Check `json:"checks"`
}

func (*Destination) HealthyWeight

func (d *Destination) HealthyWeight() uint8

If the destination is healthy then this function returns its weight. If unhealthy or disabled, zero is returned

type Director

type Director struct {
	// A channel which may be used to receive notifications of changes in status of backend servers.
	C chan bool

	Notifier mon.Notifier
	Prober   mon.Prober
	SNI      bool

	// Default IP address to use for network probes (needed for SYN, should be optional).
	Address netip.Addr
	// contains filtered or unexported fields
}

func (*Director) Configure

func (d *Director) Configure(config []Service) error

func (*Director) Start

func (d *Director) Start(cfg []Service) error

func (*Director) Status

func (d *Director) Status() (services []Service)

func (*Director) Stop

func (d *Director) Stop()

type Scheduler

type Scheduler = string

type Service

type Service struct {
	Address      netip.Addr
	Port         uint16
	Protocol     uint8
	Scheduler    string
	Persist      uint32
	Sticky       bool
	Reset        bool
	Required     uint8
	Destinations []Destination

	Up   bool
	When time.Time
	// contains filtered or unexported fields
}

func (*Service) Available

func (s *Service) Available() uint8

func (*Service) Healthy

func (s *Service) Healthy() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL