allocator

package
v0.0.0-...-c34bea4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressIterator

type AddressIterator interface {
	ForeachAddress(instanceID string, fn types.AddressIterator) error
}

AddressIterator is the required interface to allow iterating over a structure which holds a set of addresses

type Allocator

type Allocator interface {
	GetPoolQuota() types.PoolQuotaMap
	FirstPoolWithAvailableQuota(preferredPoolIDs []types.PoolID) (types.PoolID, int)
	PoolExists(poolID types.PoolID) bool
	Allocate(poolID types.PoolID, ip net.IP) error
	AllocateMany(poolID types.PoolID, num int) ([]net.IP, error)
	ReleaseMany(poolID types.PoolID, ips []net.IP) error
}

Allocator provides an IP allocator based on a list of Pools

Implementations:

  • PoolGroupAllocator
  • NoOpAllocator

type AllocatorProvider

type AllocatorProvider interface {
	Init(ctx context.Context) error
	Start(ctx context.Context, getterUpdater ipam.CiliumNodeGetterUpdater) (NodeEventHandler, error)
}

AllocatorProvider defines the functions of IPAM provider front-end these are implemented by e.g. pkg/ipam/allocator/{aws,azure}.

type NoOpAllocator

type NoOpAllocator struct{}

NoOpAllocator implements Allocator with no-op behavior

func (*NoOpAllocator) Allocate

func (n *NoOpAllocator) Allocate(poolID types.PoolID, ip net.IP) error

Allocate allocates a paritcular IP in a particular pool. This function always returns an error as this operation is not supported for the no-op allocator.

func (*NoOpAllocator) AllocateMany

func (n *NoOpAllocator) AllocateMany(poolID types.PoolID, num int) ([]net.IP, error)

AllocateMany allocates multiple IP addresses. The operation succeeds if all IPs can be allocated. On failure, all IPs are released again.

func (*NoOpAllocator) FirstPoolWithAvailableQuota

func (n *NoOpAllocator) FirstPoolWithAvailableQuota(preferredPoolIDs []types.PoolID) (types.PoolID, int)

FirstPoolWithAvailableQuota returns the first pool ID in the list of pools with available addresses. This function always returns types.PoolNotExists

func (*NoOpAllocator) GetPoolQuota

func (n *NoOpAllocator) GetPoolQuota() types.PoolQuotaMap

GetPoolQuota returns the total available pool quota. This is always 0.

func (*NoOpAllocator) PoolExists

func (n *NoOpAllocator) PoolExists(poolID types.PoolID) bool

PoolExists returns true if an allocation pool exists. This function always returns false.

func (*NoOpAllocator) ReleaseMany

func (n *NoOpAllocator) ReleaseMany(poolID types.PoolID, ips []net.IP) error

ReleaseMany releases a slice of IP addresses. This function has no effect

type NodeEventHandler

type NodeEventHandler interface {
	Create(resource *v2.CiliumNode) bool
	Update(resource *v2.CiliumNode) bool
	Delete(nodeName string)
	Resync(context.Context, time.Time)
}

NodeEventHandler should implement the behavior to handle CiliumNode

type PoolAllocator

type PoolAllocator struct {
	PoolID         types.PoolID
	AllocationCIDR *cidr.CIDR
	// contains filtered or unexported fields
}

PoolAllocator is an IP allocator allocating out of a particular CIDR pool

func NewPoolAllocator

func NewPoolAllocator(poolID types.PoolID, allocationCIDR *cidr.CIDR) (*PoolAllocator, error)

NewPoolAllocator returns a new Allocator

func (*PoolAllocator) Allocate

func (s *PoolAllocator) Allocate(ip net.IP) error

Allocate allocates a particular IP

func (*PoolAllocator) AllocateMany

func (s *PoolAllocator) AllocateMany(num int) ([]net.IP, error)

AllocateMany allocates multiple IP addresses. The operation succeeds if all IPs can be allocated. On failure, all IPs are released again.

func (*PoolAllocator) Free

func (s *PoolAllocator) Free() int

Free returns the number of available IPs for allocation

func (*PoolAllocator) ReleaseMany

func (s *PoolAllocator) ReleaseMany(ips []net.IP)

ReleaseMany releases a slice of IP addresses

type PoolGroupAllocator

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

PoolGroupAllocator is an allocator to allocate from a group of subnets

func NewPoolGroupAllocator

func NewPoolGroupAllocator(subnets types.SubnetMap) (*PoolGroupAllocator, error)

NewPoolGroupAllocator returns a new allocator able to allocate out of a group of pools.

func (*PoolGroupAllocator) Allocate

func (g *PoolGroupAllocator) Allocate(poolID types.PoolID, ip net.IP) error

Allocate allocates a paritcular IP in a particular pool

func (*PoolGroupAllocator) AllocateMany

func (g *PoolGroupAllocator) AllocateMany(poolID types.PoolID, num int) ([]net.IP, error)

AllocateMany allocates multiple IP addresses. The operation succeeds if all IPs can be allocated. On failure, all IPs are released again.

func (*PoolGroupAllocator) FirstPoolWithAvailableQuota

func (g *PoolGroupAllocator) FirstPoolWithAvailableQuota(preferredPoolIDs []types.PoolID) (types.PoolID, int)

FirstPoolWithAvailableQuota returns the first pool ID in the list of pools with available addresses. If any of the preferred pool IDs have available addresses, the first pool in that list is returned.

func (*PoolGroupAllocator) GetPoolQuota

func (g *PoolGroupAllocator) GetPoolQuota() types.PoolQuotaMap

GetPoolQuota returns the number of available IPs in all IP pools

func (*PoolGroupAllocator) PoolExists

func (g *PoolGroupAllocator) PoolExists(poolID types.PoolID) bool

PoolExists returns true if an allocation pool exists.

func (*PoolGroupAllocator) ReleaseMany

func (g *PoolGroupAllocator) ReleaseMany(poolID types.PoolID, ips []net.IP) error

ReleaseMany releases a slice of IP addresses. This function has no effect

func (*PoolGroupAllocator) ReserveAddresses

func (g *PoolGroupAllocator) ReserveAddresses(iterator AddressIterator)

ReserveAddresses reserves all addresses returned by an AddressIterator. Invalid IPs or failures to allocate are logged

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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