Documentation ¶
Overview ¶
Package experimental contains a new experimental load-balancer control-plane based on StateDB. It aims to simplify the control-plane down to fewer layers and open up the ability to modify and observe frontends and backends for variaty of use-cases without the need to special-case them.
Index ¶
- Constants
- Variables
- func FastCheckEmptyTablesAndState(db *statedb.DB, writer *Writer, bo *BPFOps) bool
- func FastCheckTables(db *statedb.DB, writer *Writer, expectedFrontends int, ...) (reconciled bool, nextRevision statedb.Revision)
- func NewBackendsTable(db *statedb.DB) (statedb.RWTable[*Backend], error)
- func NewFrontendsTable(db *statedb.DB) (statedb.RWTable[*Frontend], error)
- func NewServicesTable(db *statedb.DB) (statedb.RWTable[*Service], error)
- type BPFLBMaps
- func (r *BPFLBMaps) DeleteAffinityMatch(key *lbmap.AffinityMatchKey) error
- func (r *BPFLBMaps) DeleteBackend(key lbmap.BackendKey) error
- func (r *BPFLBMaps) DeleteMaglev(key lbmap.MaglevOuterKey, ipv6 bool) error
- func (r *BPFLBMaps) DeleteRevNat(key lbmap.RevNatKey) error
- func (r *BPFLBMaps) DeleteService(key lbmap.ServiceKey) error
- func (r *BPFLBMaps) DeleteSourceRange(key lbmap.SourceRangeKey) error
- func (r *BPFLBMaps) DumpAffinityMatch(cb func(*lbmap.AffinityMatchKey, *lbmap.AffinityMatchValue)) error
- func (r *BPFLBMaps) DumpBackend(cb func(lbmap.BackendKey, lbmap.BackendValue)) error
- func (r *BPFLBMaps) DumpMaglev(cb func(lbmap.MaglevOuterKey, lbmap.MaglevOuterVal, lbmap.MaglevInnerKey, ...)) error
- func (r *BPFLBMaps) DumpRevNat(cb func(lbmap.RevNatKey, lbmap.RevNatValue)) error
- func (r *BPFLBMaps) DumpService(cb func(lbmap.ServiceKey, lbmap.ServiceValue)) error
- func (r *BPFLBMaps) DumpSourceRange(cb func(lbmap.SourceRangeKey, *lbmap.SourceRangeValue)) error
- func (r *BPFLBMaps) IsEmpty() bool
- func (r *BPFLBMaps) Start(cell.HookContext) error
- func (r *BPFLBMaps) Stop(cell.HookContext) error
- func (r *BPFLBMaps) UpdateAffinityMatch(key *lbmap.AffinityMatchKey, value *lbmap.AffinityMatchValue) error
- func (r *BPFLBMaps) UpdateBackend(key lbmap.BackendKey, value lbmap.BackendValue) error
- func (r *BPFLBMaps) UpdateMaglev(key lbmap.MaglevOuterKey, backendIDs []loadbalancer.BackendID, ipv6 bool) error
- func (r *BPFLBMaps) UpdateRevNat(key lbmap.RevNatKey, value lbmap.RevNatValue) error
- func (r *BPFLBMaps) UpdateService(key lbmap.ServiceKey, value lbmap.ServiceValue) error
- func (r *BPFLBMaps) UpdateSourceRange(key lbmap.SourceRangeKey, value *lbmap.SourceRangeValue) error
- type BPFOps
- type Backend
- type BackendInstance
- type BackendParams
- type BackendWithRevision
- type Config
- type ExternalConfig
- type FakeLBMaps
- func (f *FakeLBMaps) DeleteAffinityMatch(key *lbmap.AffinityMatchKey) error
- func (f *FakeLBMaps) DeleteBackend(key lbmap.BackendKey) error
- func (f *FakeLBMaps) DeleteMaglev(key lbmap.MaglevOuterKey, ipv6 bool) error
- func (f *FakeLBMaps) DeleteRevNat(key lbmap.RevNatKey) error
- func (f *FakeLBMaps) DeleteService(key lbmap.ServiceKey) error
- func (f *FakeLBMaps) DeleteSourceRange(key lbmap.SourceRangeKey) error
- func (f *FakeLBMaps) DumpAffinityMatch(cb func(*lbmap.AffinityMatchKey, *lbmap.AffinityMatchValue)) error
- func (f *FakeLBMaps) DumpBackend(cb func(lbmap.BackendKey, lbmap.BackendValue)) error
- func (f *FakeLBMaps) DumpMaglev(cb func(lbmap.MaglevOuterKey, lbmap.MaglevOuterVal, lbmap.MaglevInnerKey, ...)) error
- func (f *FakeLBMaps) DumpRevNat(cb func(lbmap.RevNatKey, lbmap.RevNatValue)) error
- func (f *FakeLBMaps) DumpService(cb func(lbmap.ServiceKey, lbmap.ServiceValue)) error
- func (f *FakeLBMaps) DumpSourceRange(cb func(lbmap.SourceRangeKey, *lbmap.SourceRangeValue)) error
- func (f *FakeLBMaps) IsEmpty() bool
- func (f *FakeLBMaps) UpdateAffinityMatch(key *lbmap.AffinityMatchKey, value *lbmap.AffinityMatchValue) error
- func (f *FakeLBMaps) UpdateBackend(key lbmap.BackendKey, value lbmap.BackendValue) error
- func (f *FakeLBMaps) UpdateMaglev(key lbmap.MaglevOuterKey, backendIDs []loadbalancer.BackendID, ipv6 bool) error
- func (f *FakeLBMaps) UpdateRevNat(key lbmap.RevNatKey, value lbmap.RevNatValue) error
- func (f *FakeLBMaps) UpdateService(key lbmap.ServiceKey, value lbmap.ServiceValue) error
- func (f *FakeLBMaps) UpdateSourceRange(key lbmap.SourceRangeKey, value *lbmap.SourceRangeValue) error
- type FaultyLBMaps
- func (f *FaultyLBMaps) DeleteAffinityMatch(key *lbmap.AffinityMatchKey) error
- func (f *FaultyLBMaps) DeleteBackend(key lbmap.BackendKey) error
- func (f *FaultyLBMaps) DeleteMaglev(key lbmap.MaglevOuterKey, ipv6 bool) error
- func (f *FaultyLBMaps) DeleteRevNat(key lbmap.RevNatKey) error
- func (f *FaultyLBMaps) DeleteService(key lbmap.ServiceKey) error
- func (f *FaultyLBMaps) DeleteSourceRange(key lbmap.SourceRangeKey) error
- func (f *FaultyLBMaps) DumpAffinityMatch(cb func(*lbmap.AffinityMatchKey, *lbmap.AffinityMatchValue)) error
- func (f *FaultyLBMaps) DumpBackend(cb func(lbmap.BackendKey, lbmap.BackendValue)) error
- func (f *FaultyLBMaps) DumpMaglev(cb func(lbmap.MaglevOuterKey, lbmap.MaglevOuterVal, lbmap.MaglevInnerKey, ...)) error
- func (f *FaultyLBMaps) DumpRevNat(cb func(lbmap.RevNatKey, lbmap.RevNatValue)) error
- func (f *FaultyLBMaps) DumpService(cb func(lbmap.ServiceKey, lbmap.ServiceValue)) error
- func (f *FaultyLBMaps) DumpSourceRange(cb func(lbmap.SourceRangeKey, *lbmap.SourceRangeValue)) error
- func (f *FaultyLBMaps) IsEmpty() bool
- func (f *FaultyLBMaps) UpdateAffinityMatch(key *lbmap.AffinityMatchKey, value *lbmap.AffinityMatchValue) error
- func (f *FaultyLBMaps) UpdateBackend(key lbmap.BackendKey, value lbmap.BackendValue) error
- func (f *FaultyLBMaps) UpdateMaglev(key lbmap.MaglevOuterKey, backendIDs []loadbalancer.BackendID, ipv6 bool) error
- func (f *FaultyLBMaps) UpdateRevNat(key lbmap.RevNatKey, value lbmap.RevNatValue) error
- func (f *FaultyLBMaps) UpdateService(key lbmap.ServiceKey, value lbmap.ServiceValue) error
- func (f *FaultyLBMaps) UpdateSourceRange(key lbmap.SourceRangeKey, value *lbmap.SourceRangeValue) error
- type Frontend
- type FrontendParams
- type LBMaps
- type LBMapsConfig
- type MapDump
- type ProxyRedirect
- type Service
- type ServiceHook
- type StreamsOut
- type TestConfig
- type WriteTxn
- type Writer
- func (w *Writer) Backends() statedb.Table[*Backend]
- func (w *Writer) DebugDump(txn statedb.ReadTxn, to io.Writer)
- func (w *Writer) DeleteBackendsBySource(txn WriteTxn, source source.Source) error
- func (w *Writer) DeleteServiceAndFrontends(txn WriteTxn, name loadbalancer.ServiceName) error
- func (w *Writer) DeleteServicesBySource(txn WriteTxn, source source.Source) error
- func (w *Writer) Frontends() statedb.Table[*Frontend]
- func (w *Writer) IsEnabled() bool
- func (w *Writer) ReadTxn() statedb.ReadTxn
- func (w *Writer) RegisterInitializer(name string) (complete func(WriteTxn))
- func (w *Writer) ReleaseBackend(txn WriteTxn, name loadbalancer.ServiceName, addr loadbalancer.L3n4Addr) error
- func (w *Writer) ReleaseBackendsFromSource(txn WriteTxn, name loadbalancer.ServiceName, source source.Source) error
- func (w *Writer) Services() statedb.Table[*Service]
- func (w *Writer) SetBackendHealth(txn WriteTxn, addr loadbalancer.L3n4Addr, healthy bool) error
- func (w *Writer) SetBackends(txn WriteTxn, name loadbalancer.ServiceName, source source.Source, ...) error
- func (w *Writer) UpsertBackends(txn WriteTxn, serviceName loadbalancer.ServiceName, source source.Source, ...) error
- func (w *Writer) UpsertFrontend(txn WriteTxn, params FrontendParams) (old *Frontend, err error)
- func (w *Writer) UpsertService(txn WriteTxn, svc *Service) (old *Service, err error)
- func (w *Writer) UpsertServiceAndFrontends(txn WriteTxn, svc *Service, fes ...FrontendParams) error
- func (w *Writer) WriteTxn(extraTables ...statedb.TableMeta) WriteTxn
Constants ¶
const (
BackendTableName = "backends"
)
const (
FrontendTableName = "frontends"
)
const (
ServiceTableName = "services"
)
Variables ¶
var ( BackendByAddress = backendAddrIndex.Query BackendByServiceName = backendServiceIndex.Query )
var ( FrontendByAddress = frontendAddressIndex.Query FrontendByServiceName = frontendServiceIndex.Query )
var Cell = cell.Module( "loadbalancer-experimental", "Experimental load-balancing control-plane", cell.Config(DefaultConfig), cell.ProvidePrivate(newExternalConfig), TablesCell, ReflectorCell, cell.ProvidePrivate(resourcesToStreams), ReconcilerCell, cell.ProvidePrivate(newLBMaps, newLBMapsConfig), cell.Provide(newLBMapsCommand), )
var DefaultConfig = Config{ EnableExperimentalLB: false, RetryBackoffMin: 50 * time.Millisecond, RetryBackoffMax: time.Minute, }
var ( // ErrServiceNotFound occurs when a frontend is being upserted that refers to // a non-existing service. ErrServiceNotFound = errors.New("service not found") )
var ReconcilerCell = cell.Module( "reconciler", "Reconciles load-balancing state with BPF maps", cell.Provide( newBPFOps, newBPFReconciler, ), cell.Invoke( func(reconciler.Reconciler[*Frontend]) {}, ), )
ReconcilerCell reconciles the load-balancing state with the BPF maps.
var ReflectorCell = cell.Module( "reflector", "Reflects load-balancing state from Kubernetes", cell.Invoke(registerK8sReflector), )
ReflectorCell reflects Kubernetes Service and EndpointSlice objects to the load-balancing tables.
Note that this implementation uses Resource[*Service] and Resource[*Endpoints], which is not the desired end-game as we'll hold onto the same data multiple times. We should instead have a reflector that is built directly on the client-go reflector (k8s.RegisterReflector) and not populate an intermediate cache.Store. But as we're still experimenting it's easier to build on what already exists.
var (
ServiceByName = serviceNameIndex.Query
)
var TablesCell = cell.Module( "tables", "Experimental load-balancing control-plane", cell.ProvidePrivate( NewServicesTable, NewFrontendsTable, NewBackendsTable, ), cell.Provide( NewWriter, statedb.RWTable[*Service].ToTable, statedb.RWTable[*Frontend].ToTable, statedb.RWTable[*Backend].ToTable, ), )
TablesCell provides the Writer API for configuring load-balancing and the Table[*Service], Table[*Frontend] and Table[*Backend] for read-only access to load-balancing state.
Functions ¶
func FastCheckTables ¶
Types ¶
type BPFLBMaps ¶
type BPFLBMaps struct { // Pinned if true will pin the maps to a file. Tests may turn this off. Pinned bool Cfg LBMapsConfig // contains filtered or unexported fields }
func (*BPFLBMaps) DeleteAffinityMatch ¶
func (r *BPFLBMaps) DeleteAffinityMatch(key *lbmap.AffinityMatchKey) error
DeleteAffinityMatch implements lbmaps.
func (*BPFLBMaps) DeleteBackend ¶
func (r *BPFLBMaps) DeleteBackend(key lbmap.BackendKey) error
DeleteBackend implements lbmaps.
func (*BPFLBMaps) DeleteMaglev ¶
func (r *BPFLBMaps) DeleteMaglev(key lbmap.MaglevOuterKey, ipv6 bool) error
DeleteMaglev implements lbmaps.
func (*BPFLBMaps) DeleteRevNat ¶
DeleteRevNat implements lbmaps.
func (*BPFLBMaps) DeleteService ¶
func (r *BPFLBMaps) DeleteService(key lbmap.ServiceKey) error
DeleteService implements lbmaps.
func (*BPFLBMaps) DeleteSourceRange ¶
func (r *BPFLBMaps) DeleteSourceRange(key lbmap.SourceRangeKey) error
DeleteSourceRange implements lbmaps.
func (*BPFLBMaps) DumpAffinityMatch ¶
func (r *BPFLBMaps) DumpAffinityMatch(cb func(*lbmap.AffinityMatchKey, *lbmap.AffinityMatchValue)) error
DumpAffinityMatch implements lbmaps.
func (*BPFLBMaps) DumpBackend ¶
func (r *BPFLBMaps) DumpBackend(cb func(lbmap.BackendKey, lbmap.BackendValue)) error
DumpBackend implements lbmaps.
func (*BPFLBMaps) DumpMaglev ¶
func (r *BPFLBMaps) DumpMaglev(cb func(lbmap.MaglevOuterKey, lbmap.MaglevOuterVal, lbmap.MaglevInnerKey, *lbmap.MaglevInnerVal, bool)) error
func (*BPFLBMaps) DumpRevNat ¶
DumpRevNat implements lbmaps.
func (*BPFLBMaps) DumpService ¶
func (r *BPFLBMaps) DumpService(cb func(lbmap.ServiceKey, lbmap.ServiceValue)) error
DumpService implements lbmaps.
func (*BPFLBMaps) DumpSourceRange ¶
func (r *BPFLBMaps) DumpSourceRange(cb func(lbmap.SourceRangeKey, *lbmap.SourceRangeValue)) error
DumpSourceRange implements lbmaps.
func (*BPFLBMaps) Start ¶
func (r *BPFLBMaps) Start(cell.HookContext) error
Start implements cell.HookInterface.
func (*BPFLBMaps) Stop ¶
func (r *BPFLBMaps) Stop(cell.HookContext) error
Stop implements cell.HookInterface.
func (*BPFLBMaps) UpdateAffinityMatch ¶
func (r *BPFLBMaps) UpdateAffinityMatch(key *lbmap.AffinityMatchKey, value *lbmap.AffinityMatchValue) error
UpdateAffinityMatch implements lbmaps.
func (*BPFLBMaps) UpdateBackend ¶
func (r *BPFLBMaps) UpdateBackend(key lbmap.BackendKey, value lbmap.BackendValue) error
UpdateBackend implements lbmaps.
func (*BPFLBMaps) UpdateMaglev ¶
func (r *BPFLBMaps) UpdateMaglev(key lbmap.MaglevOuterKey, backendIDs []loadbalancer.BackendID, ipv6 bool) error
UpdateMaglev implements lbmaps.
func (*BPFLBMaps) UpdateRevNat ¶
UpdateRevNat4 implements lbmaps.
func (*BPFLBMaps) UpdateService ¶
func (r *BPFLBMaps) UpdateService(key lbmap.ServiceKey, value lbmap.ServiceValue) error
UpdateService implements lbmaps.
func (*BPFLBMaps) UpdateSourceRange ¶
func (r *BPFLBMaps) UpdateSourceRange(key lbmap.SourceRangeKey, value *lbmap.SourceRangeValue) error
UpdateSourceRange implements lbmaps.
type BPFOps ¶
type BPFOps struct { LBMaps LBMaps // contains filtered or unexported fields }
type Backend ¶
type Backend struct { loadbalancer.L3n4Addr // State is the learned state of the backend that combines the state of the // instances and the results of health checking. State loadbalancer.BackendState // Node hosting this backend. This is used to determine backends local to // a node. NodeName string // Zone where backend is located. ZoneID uint8 // Instances of this backend. A backend is always linked to a specific // service and the instances may call the backend by different name // (PortName) or they may come from differents sources. Instances part.Map[loadbalancer.ServiceName, BackendInstance] // Properties are additional untyped properties that can carry feature // specific metadata about the backend. Properties part.Map[string, any] }
Backend is a composite of the per-service backend instances that share the same IP address and port.
func (*Backend) TableHeader ¶
type BackendInstance ¶
type BackendInstance struct { // PortName is the frontend port name used for filtering the backends // associated with a service. PortName string // Weight is the load-balancing weight for this backend in association // with a specific service. Weight uint16 // Source is the data source from which this backend came from. Source source.Source // State is the backend's state as defined by the data source. This is // taken as input along with learned state (e.g. via health checking) to // construct the definite state. State loadbalancer.BackendState }
BackendInstance defines the backend's properties associated with a specific service.
type BackendParams ¶
type BackendParams struct { loadbalancer.L3n4Addr // PortName is the frontend port name. If a frontend has specified a port name // only the backends with matching port name are selected. PortName string // Weight of backend for load-balancing. Weight uint16 // Node hosting this backend. This is used to determine backends local to // a node. NodeName string // Zone where backend is located. ZoneID uint8 // State of the backend for load-balancing service traffic State loadbalancer.BackendState }
BackendParams defines the parameters of a backend for insertion into the backends table.
type BackendWithRevision ¶
type Config ¶
type ExternalConfig ¶
type ExternalConfig struct { ExternalClusterIP bool EnableSessionAffinity bool NodePortMin, NodePortMax uint16 NodePortAlg string MaglevTableSize int }
ExternalConfig are configuration options derived from external sources such as DaemonConfig. This avoids direct access of larger configuration structs.
type FakeLBMaps ¶
type FakeLBMaps struct {
// contains filtered or unexported fields
}
func (*FakeLBMaps) DeleteAffinityMatch ¶
func (f *FakeLBMaps) DeleteAffinityMatch(key *lbmap.AffinityMatchKey) error
DeleteAffinityMatch implements lbmaps.
func (*FakeLBMaps) DeleteBackend ¶
func (f *FakeLBMaps) DeleteBackend(key lbmap.BackendKey) error
DeleteBackend implements lbmaps.
func (*FakeLBMaps) DeleteMaglev ¶
func (f *FakeLBMaps) DeleteMaglev(key lbmap.MaglevOuterKey, ipv6 bool) error
DeleteMaglev implements lbmaps.
func (*FakeLBMaps) DeleteRevNat ¶
func (f *FakeLBMaps) DeleteRevNat(key lbmap.RevNatKey) error
DeleteRevNat implements lbmaps.
func (*FakeLBMaps) DeleteService ¶
func (f *FakeLBMaps) DeleteService(key lbmap.ServiceKey) error
DeleteService implements lbmaps.
func (*FakeLBMaps) DeleteSourceRange ¶
func (f *FakeLBMaps) DeleteSourceRange(key lbmap.SourceRangeKey) error
DeleteSourceRange implements lbmaps.
func (*FakeLBMaps) DumpAffinityMatch ¶
func (f *FakeLBMaps) DumpAffinityMatch(cb func(*lbmap.AffinityMatchKey, *lbmap.AffinityMatchValue)) error
DumpAffinityMatch implements lbmaps.
func (*FakeLBMaps) DumpBackend ¶
func (f *FakeLBMaps) DumpBackend(cb func(lbmap.BackendKey, lbmap.BackendValue)) error
DumpBackend implements lbmaps.
func (*FakeLBMaps) DumpMaglev ¶
func (f *FakeLBMaps) DumpMaglev(cb func(lbmap.MaglevOuterKey, lbmap.MaglevOuterVal, lbmap.MaglevInnerKey, *lbmap.MaglevInnerVal, bool)) error
func (*FakeLBMaps) DumpRevNat ¶
func (f *FakeLBMaps) DumpRevNat(cb func(lbmap.RevNatKey, lbmap.RevNatValue)) error
DumpRevNat implements lbmaps.
func (*FakeLBMaps) DumpService ¶
func (f *FakeLBMaps) DumpService(cb func(lbmap.ServiceKey, lbmap.ServiceValue)) error
DumpService implements lbmaps.
func (*FakeLBMaps) DumpSourceRange ¶
func (f *FakeLBMaps) DumpSourceRange(cb func(lbmap.SourceRangeKey, *lbmap.SourceRangeValue)) error
DumpSourceRange implements lbmaps.
func (*FakeLBMaps) UpdateAffinityMatch ¶
func (f *FakeLBMaps) UpdateAffinityMatch(key *lbmap.AffinityMatchKey, value *lbmap.AffinityMatchValue) error
UpdateAffinityMatch implements lbmaps.
func (*FakeLBMaps) UpdateBackend ¶
func (f *FakeLBMaps) UpdateBackend(key lbmap.BackendKey, value lbmap.BackendValue) error
UpdateBackend implements lbmaps.
func (*FakeLBMaps) UpdateMaglev ¶
func (f *FakeLBMaps) UpdateMaglev(key lbmap.MaglevOuterKey, backendIDs []loadbalancer.BackendID, ipv6 bool) error
UpdateMaglev implements lbmaps.
func (*FakeLBMaps) UpdateRevNat ¶
func (f *FakeLBMaps) UpdateRevNat(key lbmap.RevNatKey, value lbmap.RevNatValue) error
UpdateRevNat implements lbmaps.
func (*FakeLBMaps) UpdateService ¶
func (f *FakeLBMaps) UpdateService(key lbmap.ServiceKey, value lbmap.ServiceValue) error
UpdateService implements lbmaps.
func (*FakeLBMaps) UpdateSourceRange ¶
func (f *FakeLBMaps) UpdateSourceRange(key lbmap.SourceRangeKey, value *lbmap.SourceRangeValue) error
UpdateSourceRange implements lbmaps.
type FaultyLBMaps ¶
type FaultyLBMaps struct {
// contains filtered or unexported fields
}
func (*FaultyLBMaps) DeleteAffinityMatch ¶
func (f *FaultyLBMaps) DeleteAffinityMatch(key *lbmap.AffinityMatchKey) error
DeleteAffinityMatch implements lbmaps.
func (*FaultyLBMaps) DeleteBackend ¶
func (f *FaultyLBMaps) DeleteBackend(key lbmap.BackendKey) error
DeleteBackend implements lbmaps.
func (*FaultyLBMaps) DeleteMaglev ¶
func (f *FaultyLBMaps) DeleteMaglev(key lbmap.MaglevOuterKey, ipv6 bool) error
DeleteMaglev implements lbmaps.
func (*FaultyLBMaps) DeleteRevNat ¶
func (f *FaultyLBMaps) DeleteRevNat(key lbmap.RevNatKey) error
DeleteRevNat implements lbmaps.
func (*FaultyLBMaps) DeleteService ¶
func (f *FaultyLBMaps) DeleteService(key lbmap.ServiceKey) error
DeleteService implements lbmaps.
func (*FaultyLBMaps) DeleteSourceRange ¶
func (f *FaultyLBMaps) DeleteSourceRange(key lbmap.SourceRangeKey) error
DeleteSourceRange implements lbmaps.
func (*FaultyLBMaps) DumpAffinityMatch ¶
func (f *FaultyLBMaps) DumpAffinityMatch(cb func(*lbmap.AffinityMatchKey, *lbmap.AffinityMatchValue)) error
DumpAffinityMatch implements lbmaps.
func (*FaultyLBMaps) DumpBackend ¶
func (f *FaultyLBMaps) DumpBackend(cb func(lbmap.BackendKey, lbmap.BackendValue)) error
DumpBackend implements lbmaps.
func (*FaultyLBMaps) DumpMaglev ¶
func (f *FaultyLBMaps) DumpMaglev(cb func(lbmap.MaglevOuterKey, lbmap.MaglevOuterVal, lbmap.MaglevInnerKey, *lbmap.MaglevInnerVal, bool)) error
DumpMaglev implements lbmaps.
func (*FaultyLBMaps) DumpRevNat ¶
func (f *FaultyLBMaps) DumpRevNat(cb func(lbmap.RevNatKey, lbmap.RevNatValue)) error
DumpRevNat implements lbmaps.
func (*FaultyLBMaps) DumpService ¶
func (f *FaultyLBMaps) DumpService(cb func(lbmap.ServiceKey, lbmap.ServiceValue)) error
DumpService implements lbmaps.
func (*FaultyLBMaps) DumpSourceRange ¶
func (f *FaultyLBMaps) DumpSourceRange(cb func(lbmap.SourceRangeKey, *lbmap.SourceRangeValue)) error
DumpSourceRange implements lbmaps.
func (*FaultyLBMaps) UpdateAffinityMatch ¶
func (f *FaultyLBMaps) UpdateAffinityMatch(key *lbmap.AffinityMatchKey, value *lbmap.AffinityMatchValue) error
UpdateAffinityMatch implements lbmaps.
func (*FaultyLBMaps) UpdateBackend ¶
func (f *FaultyLBMaps) UpdateBackend(key lbmap.BackendKey, value lbmap.BackendValue) error
UpdateBackend implements lbmaps.
func (*FaultyLBMaps) UpdateMaglev ¶
func (f *FaultyLBMaps) UpdateMaglev(key lbmap.MaglevOuterKey, backendIDs []loadbalancer.BackendID, ipv6 bool) error
UpdateMaglev implements lbmaps.
func (*FaultyLBMaps) UpdateRevNat ¶
func (f *FaultyLBMaps) UpdateRevNat(key lbmap.RevNatKey, value lbmap.RevNatValue) error
UpdateRevNat implements lbmaps.
func (*FaultyLBMaps) UpdateService ¶
func (f *FaultyLBMaps) UpdateService(key lbmap.ServiceKey, value lbmap.ServiceValue) error
UpdateService implements lbmaps.
func (*FaultyLBMaps) UpdateSourceRange ¶
func (f *FaultyLBMaps) UpdateSourceRange(key lbmap.SourceRangeKey, value *lbmap.SourceRangeValue) error
UpdateSourceRange implements lbmaps.
type Frontend ¶
type Frontend struct { FrontendParams // Status is the reconciliation status for this frontend and // reflects whether or not the frontend and the associated backends // have been reconciled with the BPF maps. // Managed by [Writer]. Status reconciler.Status // Backends associated with the frontend. Backends []BackendWithRevision // contains filtered or unexported fields }
func (*Frontend) TableHeader ¶
type FrontendParams ¶
type FrontendParams struct { // Frontend address and port Address loadbalancer.L3n4Addr // Service type (e.g. ClusterIP, NodePort, ...) Type loadbalancer.SVCType // Name of the associated service ServiceName loadbalancer.ServiceName // PortName if set will select only backends with matching // port name. PortName loadbalancer.FEPortName // ServicePort is the associated "ClusterIP" port of this frontend. // Same as [Address.L4Addr.Port] except when [Type] NodePort or // LoadBalancer. This is used to match frontends with the [Ports] of // [Service.ProxyRedirect]. ServicePort uint16 }
FrontendParams defines the static parameters of a frontend. This is separate from Frontend to clearly separate which fields can be manipulated and which are internally managed by Writer.
type LBMaps ¶
type LBMaps interface { // TODO rest of the maps: // Maglev, SockRevNat, SkipLB IsEmpty() bool // contains filtered or unexported methods }
LBMaps defines the map operations performed by the reconciliation. Depending on this interface instead of on the underlying maps allows testing the implementation with a fake map or injected errors.
func NewFakeLBMaps ¶
func NewFakeLBMaps() LBMaps
type LBMapsConfig ¶
type LBMapsConfig struct { MaxSockRevNatMapEntries int ServiceMapMaxEntries, BackendMapMaxEntries, RevNatMapMaxEntries int AffinityMapMaxEntries int SourceRangeMapMaxEntries int MaglevMapMaxEntries int MaglevTableSize int }
LBMapsConfig specifies the configuration for the load-balancing BPF maps.
type MapDump ¶
type MapDump = string
MapDump is a dump of a BPF map. These are generated by the dump() method, which solely defines the format.
func DumpLBMaps ¶
func DumpLBMaps(lbmaps LBMaps, feAddr loadbalancer.L3n4Addr, sanitizeIDs bool, customIPString func(net.IP) string) (out []MapDump)
DumpLBMaps the load-balancing maps into a concise format for assertions in tests.
type ProxyRedirect ¶
type ProxyRedirect struct { ProxyPort uint16 // Ports if non-empty will only redirect a frontend with a matching port. Ports []uint16 }
func (*ProxyRedirect) Equal ¶
func (pr *ProxyRedirect) Equal(other *ProxyRedirect) bool
func (*ProxyRedirect) Redirects ¶
func (pr *ProxyRedirect) Redirects(port uint16) bool
func (*ProxyRedirect) String ¶
func (pr *ProxyRedirect) String() string
type Service ¶
type Service struct { // Name is the fully qualified service name, e.g. (<cluster>/)<namespace>/<name>. Name loadbalancer.ServiceName // Source is the data source from which this service was ingested from. Source source.Source // Labels associated with the service. Labels labels.Labels // Annotations associated with this service. Annotations map[string]string // NatPolicy defines whether we need NAT46/64 translation for backends. NatPolicy loadbalancer.SVCNatPolicy // ExtTrafficPolicy controls how backends are selected for North-South traffic. // If set to "Local", only node-local backends are chosen. ExtTrafficPolicy loadbalancer.SVCTrafficPolicy // IntTrafficPolicy controls how backends are selected for East-West traffic. // If set to "Local", only node-local backends are chosen. IntTrafficPolicy loadbalancer.SVCTrafficPolicy SessionAffinity bool SessionAffinityTimeout time.Duration // ProxyRedirect if non-nil redirects the traffic going to the frontends // towards a locally running proxy. ProxyRedirect *ProxyRedirect // HealthCheckNodePort defines on which port the node runs a HTTP health // check server which may be used by external loadbalancers to determine // if a node has local backends. This will only have effect if both // LoadBalancerIPs is not empty and ExtTrafficPolicy is SVCTrafficPolicyLocal. HealthCheckNodePort uint16 // LoopbackHostPort defines that HostPort frontends for this service should // only be exposed internally to the node. LoopbackHostPort bool // SourceRanges if non-empty will restrict access to the service to the specified // client addresses. SourceRanges []cidr.CIDR // Properties are additional untyped properties that can carry feature // specific metadata about the service. Properties part.Map[string, any] }
Service defines the common properties for a load-balancing service. Associated with a service are a set of frontends that receive the traffic, and a set of backends to which the traffic is directed. A single frontend can map to a partial subset of backends depending on its properties.
func (*Service) Clone ¶
Clone returns a shallow clone of the service, e.g. for updating a service with UpsertService. Fields that are references (e.g. Labels or Annotations) must be further cloned if mutated.
func (*Service) TableHeader ¶
type ServiceHook ¶
ServiceHook is a function invoked when a frontend has been updated. A hook can manipulate the frontend before the changes are seen by other components.
The main use-case for a hook is to set e.g. L7 proxy port before the frontend is reconciled and thus avoid unnecessary work.
For consistency the hook should only access StateDB tables via the provided read transaction.
type StreamsOut ¶
type StreamsOut struct { cell.Out ServicesStream stream.Observable[resource.Event[*slim_corev1.Service]] EndpointsStream stream.Observable[resource.Event[*k8s.Endpoints]] PodsStream stream.Observable[resource.Event[*slim_corev1.Pod]] }
type TestConfig ¶
type TestConfig struct { TestFaultProbability float32 `mapstructure:"lb-test-fault-probability"` // NodePortAlg mirrors option.Config.NodePortAlg. This can be removed when the NodePort config // flags move away from option.DaemonConfig and can thus be set directly. NodePortAlg string `mapstructure:"node-port-algorithm"` }
TestConfig are the configuration options for testing. Only provided by tests and not present in the agent.
func (TestConfig) Flags ¶
func (def TestConfig) Flags(flags *pflag.FlagSet)
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer provides validated write access to the service load-balancing state.
func (*Writer) Backends ¶
Backends returns the backend table for reading. Convenience method for reducing dependencies.
func (*Writer) DeleteBackendsBySource ¶
func (*Writer) DeleteServiceAndFrontends ¶
func (w *Writer) DeleteServiceAndFrontends(txn WriteTxn, name loadbalancer.ServiceName) error
func (*Writer) DeleteServicesBySource ¶
DeleteServicesBySource deletes all services from the specific source. This is used to implement "resynchronization", for example with K8s when the Watch() call fails and we need to start over with a List().
func (*Writer) Frontends ¶
Frontends returns the frontend table for reading. Convenience method for reducing dependencies.
func (*Writer) ReadTxn ¶
ReadTxn returns a StateDB read transaction. Convenience method to be used with the above table getters.
func (*Writer) RegisterInitializer ¶
RegisterInitializer registers a component as an initializer to the load-balancing tables. This blocks pruning of data until this and all other registered initializers have called the returned 'complete' function.
func (*Writer) ReleaseBackend ¶
func (w *Writer) ReleaseBackend(txn WriteTxn, name loadbalancer.ServiceName, addr loadbalancer.L3n4Addr) error
func (*Writer) ReleaseBackendsFromSource ¶
func (w *Writer) ReleaseBackendsFromSource(txn WriteTxn, name loadbalancer.ServiceName, source source.Source) error
func (*Writer) Services ¶
Services returns the service table for reading. Convenience method for reducing dependencies.
func (*Writer) SetBackendHealth ¶
func (*Writer) SetBackends ¶
func (w *Writer) SetBackends(txn WriteTxn, name loadbalancer.ServiceName, source source.Source, bes ...BackendParams) error
SetBackends sets the backends associated with a service. Existing backends from this source that are associated with the service but are not given are released.
func (*Writer) UpsertBackends ¶
func (w *Writer) UpsertBackends(txn WriteTxn, serviceName loadbalancer.ServiceName, source source.Source, bes ...BackendParams) error
UpsertBackends adds/updates backends for the given service.
func (*Writer) UpsertFrontend ¶
func (w *Writer) UpsertFrontend(txn WriteTxn, params FrontendParams) (old *Frontend, err error)
func (*Writer) UpsertService ¶
func (*Writer) UpsertServiceAndFrontends ¶
func (w *Writer) UpsertServiceAndFrontends(txn WriteTxn, svc *Service, fes ...FrontendParams) error
UpsertServiceAndFrontends upserts the service and updates the set of associated frontends. Any frontends that do not exist in the new set are deleted.