Documentation ¶
Index ¶
- type AddressIterator
- type Allocator
- type AllocatorProvider
- type NetResourceSetEventHandler
- type NoOpAllocator
- func (n *NoOpAllocator) Allocate(poolID types.PoolID, ip net.IP) error
- func (n *NoOpAllocator) AllocateMany(poolID types.PoolID, num int) ([]net.IP, error)
- func (n *NoOpAllocator) FirstPoolWithAvailableQuota(preferredPoolIDs []types.PoolID) (types.PoolID, int)
- func (n *NoOpAllocator) GetPoolQuota() types.PoolQuotaMap
- func (n *NoOpAllocator) PoolExists(poolID types.PoolID) bool
- func (n *NoOpAllocator) ReleaseMany(poolID types.PoolID, ips []net.IP) error
- type PoolAllocator
- type PoolGroupAllocator
- func (g *PoolGroupAllocator) Allocate(poolID types.PoolID, ip net.IP) error
- func (g *PoolGroupAllocator) AllocateMany(poolID types.PoolID, num int) ([]net.IP, error)
- func (g *PoolGroupAllocator) FirstPoolWithAvailableQuota(preferredPoolIDs []types.PoolID) (types.PoolID, int)
- func (g *PoolGroupAllocator) GetPoolQuota() types.PoolQuotaMap
- func (g *PoolGroupAllocator) PoolExists(poolID types.PoolID) bool
- func (g *PoolGroupAllocator) ReleaseMany(poolID types.PoolID, ips []net.IP) error
- func (g *PoolGroupAllocator) ReserveAddresses(iterator AddressIterator)
- type SubRangePoolAllocator
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.NetResourceSetGetterUpdater) (NetResourceSetEventHandler, error) }
AllocatorProvider defines the functions of IPAM provider front-end these are implemented by e.g. pkg/ipam/allocator/{aws,azure}.
type NetResourceSetEventHandler ¶
type NetResourceSetEventHandler interface { Create(resource *v2.NetResourceSet) error Update(resource *v2.NetResourceSet) error Delete(netResourceSetName string) error Resync(context.Context, time.Time) ResourceType() string }
NetResourceSetEventHandler should implement the behavior to handle NetResourceSet
type NoOpAllocator ¶
type NoOpAllocator struct{}
NoOpAllocator implements Allocator with no-op behavior
func (*NoOpAllocator) Allocate ¶
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 ¶
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 ¶
ReleaseMany releases a slice of IP addresses. This function has no effect
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 ¶
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) AllocateMany ¶
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 ¶
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
type SubRangePoolAllocator ¶
type SubRangePoolAllocator struct {
*PoolAllocator
}
func NewSubRangePoolAllocator ¶
func NewSubRangePoolAllocator(poolID types.PoolID, allocationCIDR *cidr.CIDR, reserve int) (*SubRangePoolAllocator, error)
NewSubRangePoolAllocator returns a new Allocator
func (*SubRangePoolAllocator) ReservedAllocateMany ¶
func (s *SubRangePoolAllocator) ReservedAllocateMany(startIP, endIP net.IP, num int) ([]net.IP, error)
ReservedAllocateMany reserves a slice of IP addresses