allocator

package
v0.14.9 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocation added in v0.14.9

type Allocation struct {
	PoolName string
	IPV4     net.IP
	IPV6     net.IP
}

Allocation represents a mapping of IP families (IPv4, IPv6, or both) to their respective IP addresses. This type is used to select and organize IPs based on a service's IP family policy. Depending on the family policy, the map may contain: - Just an IPv4 address - Just an IPv6 address - Both IPv4 and IPv6 addresses for dual-stack support.

Key: - ipfamily.IPv4: Corresponds to the IPv4 address allocated for the service. - ipfamily.IPv6: Corresponds to the IPv6 address allocated for the service.

type Allocator

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

An Allocator tracks IP address pools and allocates addresses from them.

func New

func New() *Allocator

New returns an Allocator managing no pools.

func (*Allocator) Allocate

func (a *Allocator) Allocate(
	svcKey string,
	svc *v1.Service,
	serviceIPFamily ipfamily.Family,
	ports []Port,
	sharingKey, backendKey string,
) ([]net.IP, error)

Allocate chooses the most suitable pool and assigns an available IP from that pool to the service.

func (*Allocator) AllocateFromPool

func (a *Allocator) AllocateFromPool(
	svcKey string,
	svc *v1.Service,
	serviceIPFamily ipfamily.Family,
	poolName string,
	ports []Port,
	sharingKey,
	backendKey string,
) ([]net.IP, error)

AllocateFromPool assigns an available IP from pool to service.

func (*Allocator) AllocateFromPoolForAdditionalFamily added in v0.14.9

func (a *Allocator) AllocateFromPoolForAdditionalFamily(
	svcKey string,
	svc *v1.Service,
	existingIP net.IP,
	poolName string,
	ports []Port,
	sharingKey,
	backendKey string,
) (net.IP, error)

AllocateIPFromPoolForAdditionalFamily works specially for the preferDualStack ipfamily policy in case there is only 1 assigned ip. It tries to allocate an additional ip from the missing family while retaining the ip already allocated to the svc.

func (*Allocator) Assign

func (a *Allocator) Assign(svcKey string, svc *v1.Service, ips []net.IP, ports []Port, sharingKey, backendKey string) error

Assign assigns the requested ip to svc, if the assignment is permissible by sharingKey and backendKey.

func (*Allocator) IPs added in v0.14.0

func (a *Allocator) IPs(svc string) []net.IP

IPs returns the allocated IPs of a service.

func (*Allocator) Pool added in v0.3.0

func (a *Allocator) Pool(svc string) string

Pool returns the pool from which service's IP was allocated. If service has no IP allocated, "" is returned.

func (*Allocator) PoolForIP added in v0.14.0

func (a *Allocator) PoolForIP(ips []net.IP) *config.Pool

PoolForIP returns the pool structure associated with an IP.

func (*Allocator) SetPools

func (a *Allocator) SetPools(pools *config.Pools)

SetPools updates the set of address pools that the allocator owns.

func (*Allocator) Unassign

func (a *Allocator) Unassign(svc string)

Unassign frees the IP associated with service, if any.

type Port added in v0.6.0

type Port struct {
	Proto string
	Port  int
}

Port represents one port in use by a service.

func (Port) String added in v0.6.0

func (p Port) String() string

String returns a text description of the port.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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