Documentation
¶
Overview ¶
Package allocator provides CIDR allocation functionality for Kubernetes nodes.
Index ¶
- Variables
- func ParseCIDRs(cidrs []string) ([]*net.IPNet, error)
- type Allocator
- func (a *Allocator) AllocateIPv4() (string, error)
- func (a *Allocator) AllocateIPv6() (string, error)
- func (a *Allocator) ContainsCIDR(cidr string) bool
- func (a *Allocator) DebugState() AllocatorDebugState
- func (a *Allocator) HasIPv4Pools() bool
- func (a *Allocator) HasIPv6Pools() bool
- func (a *Allocator) IsAllocated(cidr string) bool
- func (a *Allocator) MarkAllocated(cidr string)
- func (a *Allocator) Release(cidr string)
- func (a *Allocator) Reset()
- type AllocatorDebugState
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPoolExhausted is returned when no more CIDRs are available for allocation. ErrPoolExhausted = errors.New("CIDR pool exhausted") // ErrInvalidMaskSize is returned when the mask size is invalid for the given pool. ErrInvalidMaskSize = errors.New("invalid mask size for pool") )
Functions ¶
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator manages CIDR allocation from configured pools.
func NewAllocator ¶
func NewAllocator(ipv4Pools, ipv6Pools []*net.IPNet, ipv4MaskSize, ipv6MaskSize int) (*Allocator, error)
NewAllocator creates a new CIDR allocator with the given pools and mask sizes. Returns an error if the mask sizes are invalid for the given pools.
func (*Allocator) AllocateIPv4 ¶
AllocateIPv4 allocates the next available IPv4 CIDR from the pools. Returns ErrPoolExhausted if no CIDRs are available.
func (*Allocator) AllocateIPv6 ¶
AllocateIPv6 allocates the next available IPv6 CIDR from the pools. Returns ErrPoolExhausted if no CIDRs are available.
func (*Allocator) ContainsCIDR ¶
ContainsCIDR returns true if the given CIDR falls within any of the allocator's pools.
func (*Allocator) DebugState ¶
func (a *Allocator) DebugState() AllocatorDebugState
DebugState returns a snapshot of the allocator's internal state.
func (*Allocator) HasIPv4Pools ¶
HasIPv4Pools returns true if IPv4 pools are configured.
func (*Allocator) HasIPv6Pools ¶
HasIPv6Pools returns true if IPv6 pools are configured.
func (*Allocator) IsAllocated ¶
IsAllocated checks if a CIDR is already allocated.
func (*Allocator) MarkAllocated ¶
MarkAllocated marks a CIDR as already allocated. This should be called for all existing node podCIDRs during startup.
type AllocatorDebugState ¶
type AllocatorDebugState struct {
IPv4Pools []string `json:"ipv4Pools"`
IPv6Pools []string `json:"ipv6Pools"`
IPv4MaskSize int `json:"ipv4MaskSize"`
IPv6MaskSize int `json:"ipv6MaskSize"`
AllocatedCount int `json:"allocatedCount"`
AllocatedCIDRs []string `json:"allocatedCIDRs"`
}
AllocatorDebugState contains a snapshot of allocator internal state.