core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Check() (string, error)
	Setup() error
	EnsureIPAdvertisement(ip netip.Addr, interfaceName string) (string, error)
	DeleteIPAdvertisement(ip netip.Addr) error
	EnsureService(svc *Service) error
	DeleteService(name, uid string) error
}

type Config

type Config struct {
	// Metrics and health probe options
	MetricsAddr string `env:"METRICS_ADDR,default=:8080"`
	ProbeAddr   string `env:"PROBE_ADDR,default=:8081"`

	// Webhook options
	WebhookPort    int    `env:"WEBHOOK_PORT,default=9443"`
	WebhookCertDir string `env:"WEBHOOK_CERT_DIR,default=/mnt/k8s-webhook-server/serving-certs"`

	// RouterOS options
	RouterOSURL          *url.URL      `env:"ROUTEROS_URL,required"`
	RouterOSUsername     string        `env:"ROUTEROS_USERNAME,required"`
	RouterOSPassword     string        `env:"ROUTEROS_PASSWORD,required"`
	RouterOSCACert       string        `env:"ROUTEROS_CA_CERT"`
	RouterOSCacheTimeout time.Duration `env:"ROUTEROS_CACHE_TIMEOUT,default=5m"`

	// Controller options
	LoadBalancerClassName string `env:"LOAD_BALANCER_CLASS_NAME,default=mikrolb.de/controller"`
	IsDefaultLoadBalancer bool   `env:"LOAD_BALANCER_DEFAULT,default=false"`

	// Reconciliation options
	AllocationTimeout time.Duration `env:"ALLOCATION_TIMEOUT,default=5m"`
}

func LoadConfig

func LoadConfig(ctx context.Context) (*Config, error)

type Endpoint

type Endpoint struct {
	IPs   []netip.Addr
	Ports []EndpointPort
}

type EndpointPort

type EndpointPort struct {
	Port       uint16
	TargetPort uint16
	Protocol   string
}

type IPFamily

type IPFamily string
const (
	IPv4 IPFamily = "IPv4"
	IPv6 IPFamily = "IPv6"
)

func GetIPFamily

func GetIPFamily(ip netip.Addr) IPFamily

type IPRange

type IPRange struct {
	// contains filtered or unexported fields
}

func NewIPRange

func NewIPRange(start, end netip.Addr) (IPRange, error)

func ParseIPRange

func ParseIPRange(s string, excludeCIDREdges bool) (ipRange IPRange, isExcluded bool, err error)

func (*IPRange) Contains

func (r *IPRange) Contains(addr netip.Addr) bool

func (*IPRange) Count

func (r *IPRange) Count() *big.Int

func (*IPRange) IPFamily

func (r *IPRange) IPFamily() IPFamily

func (*IPRange) Iter

func (r *IPRange) Iter(startHash [16]byte) func(yield func(netip.Addr) bool)

func (*IPRange) Overlaps

func (r *IPRange) Overlaps(other IPRange) bool

func (IPRange) String

func (r IPRange) String() string

type IPRangeSet

type IPRangeSet struct {
	// contains filtered or unexported fields
}

func NewIPRangeSet

func NewIPRangeSet(rs ...IPRange) IPRangeSet

func (*IPRangeSet) Contains

func (s *IPRangeSet) Contains(ip netip.Addr) bool

func (*IPRangeSet) Count

func (s *IPRangeSet) Count(ipFamily IPFamily) *big.Int

func (*IPRangeSet) HasRangesOfFamily

func (s *IPRangeSet) HasRangesOfFamily(ipFamily IPFamily) bool

func (*IPRangeSet) Intersections

func (s *IPRangeSet) Intersections(rs IPRangeSet) IPRangeSet

func (*IPRangeSet) Merge

func (s *IPRangeSet) Merge(rs ...IPRange)

func (*IPRangeSet) Ranges

func (s *IPRangeSet) Ranges() []IPRange

func (*IPRangeSet) RangesForFamily

func (s *IPRangeSet) RangesForFamily(ipFamily IPFamily) []IPRange

func (*IPRangeSet) String

func (s *IPRangeSet) String() string

func (*IPRangeSet) Subtract

func (s *IPRangeSet) Subtract(rs ...IPRange)

type Service

type Service struct {
	UID         string
	Name        string
	LBEnabled   bool
	LBIPs       []netip.Addr
	SNATEnabled bool
	SNATIPv4    netip.Addr
	SNATIPv6    netip.Addr
	Endpoints   []Endpoint
}

func (*Service) GetAllIPs

func (s *Service) GetAllIPs() []netip.Addr

func (*Service) HasLBIP

func (s *Service) HasLBIP(family IPFamily) bool

func (*Service) HasSNATIP

func (s *Service) HasSNATIP(family IPFamily) bool

func (Service) MarshalLogObject

func (s Service) MarshalLogObject(enc zapcore.ObjectEncoder) error

Jump to

Keyboard shortcuts

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