reflectors

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cell = cell.Module(
	"loadbalancer-reflectors",
	"Reflects external state to load-balancing tables",

	K8sReflectorCell,

	FileReflectorCell,
)
View Source
var FileReflectorCell = cell.Module(
	"file-reflector",
	"Synchronizes load-balancing state from a file",

	cell.Config(fileReflectorConfig{}),
	cell.Invoke(registerFileReflector),
)

FileReflectorCell synchronizes the load-balancing state from a file specified with --lb-state-file. The file format is specified by StateFile and consists of Kubernetes services and endpoint slices.

The Kubernetes definitions are used to avoid having a new format and conversions from that format and it is also familiar to users.

The implementation is tested by 'pkg/loadbalancer/tests/testdata/file.txtar' which also shows an example of the file format.

View Source
var K8sReflectorCell = cell.Module(
	"k8s-reflector",
	"Reflects load-balancing state from Kubernetes",

	cell.ProvidePrivate(resourcesToStreams),
	cell.Invoke(RegisterK8sReflector),
)

K8sReflectorCell 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.

Functions

func CheckServiceNodeExposure

func CheckServiceNodeExposure(localNodeStore *node.LocalNodeStore, annotations map[string]string) (bool, error)

CheckServiceNodeExposure returns true if the service should be installed onto the local node, and false if the node should ignore and not install the service.

func NewSvcExposureType

func NewSvcExposureType(svc *slim_corev1.Service) (*exposeSvcType, error)

func RegisterK8sReflector

func RegisterK8sReflector(p reflectorParams)

Types

type SVCMetrics

type SVCMetrics interface {
	AddService(svc *loadbalancer.Service)
	DelService(svc *loadbalancer.Service)
}

func NewSVCMetricsNoop

func NewSVCMetricsNoop() SVCMetrics

type StateFile

type StateFile struct {
	Services  []slim_corev1.Service            `json:"services"`
	Endpoints []slim_discoveryv1.EndpointSlice `json:"endpoints"`
}

StateFile defines the format for the state file used with --lb-state-file.

type StreamsOut

type StreamsOut struct {
	cell.Out
	ServicesStream  stream.Observable[resource.Event[*slim_corev1.Service]]
	EndpointsStream stream.Observable[resource.Event[*k8s.Endpoints]]
}

Jump to

Keyboard shortcuts

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