Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidFamilyMode(ipFamily IPFamilyMode) bool
- func IsValidNetworkType(networkType NetworkType) bool
- type AdditionalLabels
- type AllocateOption
- type AllocateOptions
- type AllocateSubnets
- type AssignForce
- type AssignOption
- type AssignOptions
- type CoupleOption
- type CoupleOptions
- type DropPodName
- type IP
- type IPFamilyMode
- type IPSet
- type IPSlice
- type Network
- func (n *Network) AddSubnet(subnet *Subnet, ips IPSet) error
- func (n *Network) GetDualStackSubnetsByNameOrAvailable(v4SubnetName, v6SubnetName string) (v4Subnet *Subnet, v6Subnet *Subnet, err error)
- func (n *Network) GetIPv4SubnetByNameOrAvailable(subnetName string) (sn *Subnet, err error)
- func (n *Network) GetIPv6SubnetByNameOrAvailable(subnetName string) (sn *Subnet, err error)
- func (n *Network) GetSubnetByName(subnetName string) (*Subnet, error)
- func (n *Network) GetSubnetByNameOrIP(subnetName, ip string) (*Subnet, error)
- func (n *Network) SubnetCount() int
- func (n *Network) Usage() *NetworkUsage
- type NetworkSet
- func (n NetworkSet) CheckNetworkByType(networkName string, networkType NetworkType) bool
- func (n NetworkSet) GetNetworkByName(name string) (*Network, error)
- func (n NetworkSet) ListNetworkToNames() []string
- func (n NetworkSet) RefreshNetwork(name string, network *Network)
- func (n NetworkSet) RemoveNetwork(name string)
- type NetworkType
- type NetworkUsage
- type OwnerReference
- type PodInfo
- type ReCoupleOption
- type ReCoupleOptions
- type RefreshForceAll
- type RefreshNetworks
- type RefreshOption
- type RefreshOptions
- type ReserveOption
- type ReserveOptions
- type SpecifiedMACAddress
- type Subnet
- func (s *Subnet) AllocateNext(podName, podNamespace string) *IP
- func (s *Subnet) Assign(podName, podNamespace, ip string, forced bool) (*IP, error)
- func (s *Subnet) Canonicalize() error
- func (s *Subnet) Contains(addr net.IP) bool
- func (s *Subnet) IsAvailable() bool
- func (s *Subnet) IsBlackIP(ip string) bool
- func (s *Subnet) IsIPv4() bool
- func (s *Subnet) IsIPv6() bool
- func (s *Subnet) IsReservedIP(ip string) bool
- func (s *Subnet) Overlap(s1 *Subnet) bool
- func (s *Subnet) Release(ip string)
- func (s *Subnet) Reserve(ip string)
- func (s *Subnet) Sync(parentNetID *uint32, ipSet IPSet) error
- func (s *Subnet) Usage() *Usage
- func (s *Subnet) UsingIPCount() int
- func (s *Subnet) Validate() error
- type SubnetIPSuite
- type SubnetSlice
- func (s *SubnetSlice) AddSubnet(subnet *Subnet, parentNetID *uint32, ips IPSet) error
- func (s *SubnetSlice) Count() int
- func (s *SubnetSlice) CurrentSubnetName() string
- func (s *SubnetSlice) GetAvailableSubnet() (*Subnet, error)
- func (s *SubnetSlice) GetSubnet(name string) (*Subnet, error)
- func (s *SubnetSlice) GetSubnetByIP(ip string) (*Subnet, error)
- func (s *SubnetSlice) Usage() *Usage
- type Usage
Constants ¶
const ( IPv4 = IPFamilyMode("IPv4Only") IPv6 = IPFamilyMode("IPv6Only") DualStack = IPFamilyMode("DualStack") )
const ( IPv4Alias = "IPv4" IPv6Alias = "IPv6" )
short aliases
const ( Underlay = NetworkType("Underlay") Overlay = NetworkType("Overlay") GlobalBGP = NetworkType("GlobalBGP") )
const ( IPStatusAllocated = "Allocated" IPStatusReserved = "Reserved" )
Variables ¶
var ( ErrNotFoundNetwork = errors.New("network not found") ErrEmptySubnetName = errors.New("subnet name must be specified") )
Functions ¶
func IsValidFamilyMode ¶ added in v0.7.0
func IsValidFamilyMode(ipFamily IPFamilyMode) bool
func IsValidNetworkType ¶ added in v0.7.0
func IsValidNetworkType(networkType NetworkType) bool
Types ¶
type AdditionalLabels ¶ added in v0.6.0
func (AdditionalLabels) ApplyToCouple ¶ added in v0.6.0
func (a AdditionalLabels) ApplyToCouple(options *CoupleOptions)
func (AdditionalLabels) ApplyToReCouple ¶ added in v0.6.0
func (a AdditionalLabels) ApplyToReCouple(options *ReCoupleOptions)
type AllocateOption ¶ added in v0.6.0
type AllocateOption interface {
ApplyToAllocate(*AllocateOptions)
}
type AllocateOptions ¶ added in v0.6.0
type AllocateOptions struct { // Subnets is the specified subnet list where IP should be allocated from Subnets []string }
AllocateOptions is a collection of all configurable configs for Allocate action
func (*AllocateOptions) ApplyOptions ¶ added in v0.6.0
func (a *AllocateOptions) ApplyOptions(opts []AllocateOption)
type AllocateSubnets ¶ added in v0.6.0
type AllocateSubnets []string
func (AllocateSubnets) ApplyToAllocate ¶ added in v0.6.0
func (a AllocateSubnets) ApplyToAllocate(options *AllocateOptions)
type AssignForce ¶ added in v0.6.0
type AssignForce bool
func (AssignForce) ApplyToAssign ¶ added in v0.6.0
func (a AssignForce) ApplyToAssign(options *AssignOptions)
type AssignOption ¶ added in v0.6.0
type AssignOption interface {
ApplyToAssign(options *AssignOptions)
}
type AssignOptions ¶ added in v0.6.0
type AssignOptions struct { // Force means this assignment can force to use reserved IP Force bool }
AssignOptions is a collection of all configurable configs for Assign action
func (*AssignOptions) ApplyOptions ¶ added in v0.6.0
func (a *AssignOptions) ApplyOptions(opts []AssignOption)
type CoupleOption ¶ added in v0.6.0
type CoupleOption interface {
ApplyToCouple(*CoupleOptions)
}
type CoupleOptions ¶ added in v0.6.0
type CoupleOptions struct { // AdditionalLabels will be patched to IP when coupling AdditionalLabels map[string]string // SpecifiedMACAddress will be used as mac address of Pod SpecifiedMACAddress SpecifiedMACAddress // OwnerReference will replace the owner reference fetched from Pod explicitly OwnerReference *metav1.OwnerReference }
CoupleOptions is a collection of all configurable configs for Couple action
func (*CoupleOptions) ApplyOptions ¶ added in v0.6.0
func (c *CoupleOptions) ApplyOptions(opts []CoupleOption)
type DropPodName ¶ added in v0.6.0
type DropPodName bool
func (DropPodName) ApplyToReserve ¶ added in v0.6.0
func (d DropPodName) ApplyToReserve(options *ReserveOptions)
type IP ¶
type IPFamilyMode ¶
type IPFamilyMode string
func ParseIPFamilyFromEnv ¶ added in v0.4.3
func ParseIPFamilyFromEnv() IPFamilyMode
func ParseIPFamilyFromEnvOnce ¶ added in v0.4.3
func ParseIPFamilyFromEnvOnce() IPFamilyMode
func ParseIPFamilyFromString ¶
func ParseIPFamilyFromString(in string) IPFamilyMode
type IPSet ¶
func (IPSet) UpdateStatus ¶ added in v0.6.0
type IPSlice ¶
func NewIPSlice ¶
func NewIPSlice() *IPSlice
type Network ¶
type Network struct { // Spec fields Name string NetID *uint32 Type NetworkType IPv4Subnets *SubnetSlice IPv6Subnets *SubnetSlice }
func NewNetwork ¶
func NewNetwork(name string, netID *uint32, lastAllocatedSubnet, lastAllocatedIPv6Subnet string, networkType NetworkType) *Network
func (*Network) GetDualStackSubnetsByNameOrAvailable ¶ added in v0.6.0
func (*Network) GetIPv4SubnetByNameOrAvailable ¶ added in v0.6.0
func (*Network) GetIPv6SubnetByNameOrAvailable ¶ added in v0.6.0
func (*Network) GetSubnetByName ¶ added in v0.6.0
func (*Network) GetSubnetByNameOrIP ¶ added in v0.6.0
func (*Network) SubnetCount ¶ added in v0.7.0
func (*Network) Usage ¶
func (n *Network) Usage() *NetworkUsage
type NetworkSet ¶
func NewNetworkSet ¶
func NewNetworkSet() NetworkSet
func (NetworkSet) CheckNetworkByType ¶ added in v0.7.0
func (n NetworkSet) CheckNetworkByType(networkName string, networkType NetworkType) bool
func (NetworkSet) GetNetworkByName ¶ added in v0.7.0
func (n NetworkSet) GetNetworkByName(name string) (*Network, error)
func (NetworkSet) ListNetworkToNames ¶ added in v0.7.0
func (n NetworkSet) ListNetworkToNames() []string
func (NetworkSet) RefreshNetwork ¶
func (n NetworkSet) RefreshNetwork(name string, network *Network)
func (NetworkSet) RemoveNetwork ¶
func (n NetworkSet) RemoveNetwork(name string)
type NetworkType ¶
type NetworkType string
func ParseNetworkTypeFromEnv ¶
func ParseNetworkTypeFromEnv() NetworkType
func ParseNetworkTypeFromEnvOnce ¶ added in v0.5.0
func ParseNetworkTypeFromEnvOnce() NetworkType
func ParseNetworkTypeFromString ¶
func ParseNetworkTypeFromString(in string) NetworkType
type NetworkUsage ¶ added in v0.6.0
type NetworkUsage struct {
Usages map[IPFamilyMode]*Usage
}
func (*NetworkUsage) GetByType ¶ added in v0.6.0
func (n *NetworkUsage) GetByType(ipFamily IPFamilyMode) *Usage
type OwnerReference ¶ added in v0.6.0
type OwnerReference metav1.OwnerReference
func ResetOwnerReference ¶ added in v0.6.0
func ResetOwnerReference(orig *metav1.OwnerReference) OwnerReference
func (OwnerReference) ApplyToCouple ¶ added in v0.6.0
func (o OwnerReference) ApplyToCouple(options *CoupleOptions)
func (OwnerReference) ApplyToReCouple ¶ added in v0.6.0
func (o OwnerReference) ApplyToReCouple(options *ReCoupleOptions)
type PodInfo ¶ added in v0.6.0
type PodInfo struct { types.NamespacedName IPFamily IPFamilyMode }
type ReCoupleOption ¶ added in v0.6.0
type ReCoupleOption interface {
ApplyToReCouple(*ReCoupleOptions)
}
type ReCoupleOptions ¶ added in v0.6.0
type ReCoupleOptions struct { // AdditionalLabels will be patched to IP when recoupling AdditionalLabels map[string]string // SpecifiedMACAddress will be used as mac address of Pod SpecifiedMACAddress SpecifiedMACAddress // OwnerReference will replace the owner reference fetched from Pod explicitly OwnerReference *metav1.OwnerReference }
ReCoupleOptions is a collection of all configurable configs for ReCouple action
func (*ReCoupleOptions) ApplyOptions ¶ added in v0.6.0
func (r *ReCoupleOptions) ApplyOptions(opts []ReCoupleOption)
type RefreshForceAll ¶ added in v0.6.0
type RefreshForceAll bool
func (RefreshForceAll) ApplyToRefresh ¶ added in v0.6.0
func (r RefreshForceAll) ApplyToRefresh(options *RefreshOptions)
type RefreshNetworks ¶ added in v0.6.0
type RefreshNetworks []string
func (RefreshNetworks) ApplyToRefresh ¶ added in v0.6.0
func (r RefreshNetworks) ApplyToRefresh(options *RefreshOptions)
type RefreshOption ¶ added in v0.6.0
type RefreshOption interface {
ApplyToRefresh(*RefreshOptions)
}
type RefreshOptions ¶ added in v0.6.0
type RefreshOptions struct { // ForceAll will force all registered networks to be refreshed ForceAll bool // Networks is the specified network list to be refreshed Networks []string }
RefreshOptions is a collection of all configurable configs for Refresh action
func (*RefreshOptions) ApplyOptions ¶ added in v0.6.0
func (r *RefreshOptions) ApplyOptions(opts []RefreshOption)
type ReserveOption ¶ added in v0.6.0
type ReserveOption interface {
ApplyToReserve(*ReserveOptions)
}
type ReserveOptions ¶ added in v0.6.0
type ReserveOptions struct { // DropPodName means this reservation will drop pod name binding, // if pod name will change when IP reservation, set it true DropPodName bool }
ReserveOptions is a coolection of all configurable configs for Reserve action
func (*ReserveOptions) ApplyOptions ¶ added in v0.6.0
func (r *ReserveOptions) ApplyOptions(opts []ReserveOption)
type SpecifiedMACAddress ¶ added in v0.7.0
type SpecifiedMACAddress string
func (SpecifiedMACAddress) ApplyToCouple ¶ added in v0.7.0
func (s SpecifiedMACAddress) ApplyToCouple(options *CoupleOptions)
func (SpecifiedMACAddress) ApplyToReCouple ¶ added in v0.7.0
func (s SpecifiedMACAddress) ApplyToReCouple(options *ReCoupleOptions)
func (SpecifiedMACAddress) EqualsTo ¶ added in v0.7.0
func (s SpecifiedMACAddress) EqualsTo(normalizedMACAddr string) bool
EqualsTo returns whether current specified MAC address is equal to another normalized MAC address.
func (SpecifiedMACAddress) IsEmpty ¶ added in v0.7.0
func (s SpecifiedMACAddress) IsEmpty() bool
type Subnet ¶
type Subnet struct { // Spec fields // `Canonicalize` method will initialize these Name string ParentNetwork string NetID *uint32 Start net.IP End net.IP CIDR *net.IPNet Gateway net.IP ReservedList map[string]struct{} BlackList map[string]struct{} LastAllocatedIP net.IP Private bool IPv6 bool // Status fields // `Sync` method will initialize these AvailableIPs *IPSlice UsingIPs IPSet ReservedIPCount int }
func (*Subnet) AllocateNext ¶
func (*Subnet) Canonicalize ¶
Canonicalize takes a given subnet and ensures that all information is consistent, filling out Start, End, and Gateway with sane values if missing
func (*Subnet) Contains ¶
Contains checks if a given ip is a valid, allocatable address in a given Range This address should be in CIDR [start,gw) (gw,end], and not in black list.
func (*Subnet) IsAvailable ¶
func (*Subnet) IsReservedIP ¶
func (*Subnet) Sync ¶
Sync will generate netID, filtered Reserved List, Available IP Slice and Using IP Set based on subnet spec and input
func (*Subnet) UsingIPCount ¶
UsingIPCount will count the IP which are being used, but the reserved IPs will be excluded
type SubnetIPSuite ¶ added in v0.6.0
func AssignIP ¶ added in v0.6.0
func AssignIP(ip string) SubnetIPSuite
func AssignIPOfSubnet ¶ added in v0.6.0
func AssignIPOfSubnet(subnet, ip string) SubnetIPSuite
func ReleaseIPOfSubnet ¶ added in v0.6.0
func ReleaseIPOfSubnet(subnet, ip string) SubnetIPSuite
func ReserveIPOfSubnet ¶ added in v0.6.0
func ReserveIPOfSubnet(subnet, ip string) SubnetIPSuite
type SubnetSlice ¶
type SubnetSlice struct { Subnets []*Subnet SubnetIndexMap map[string]int SubnetIndex int SubnetCount int LastAllocatedSubnet string }
func NewSubnetSlice ¶
func NewSubnetSlice(lastAllocatedSubnet string) *SubnetSlice
func (*SubnetSlice) AddSubnet ¶
func (s *SubnetSlice) AddSubnet(subnet *Subnet, parentNetID *uint32, ips IPSet) error
func (*SubnetSlice) Count ¶ added in v0.7.0
func (s *SubnetSlice) Count() int
func (*SubnetSlice) CurrentSubnetName ¶ added in v0.7.0
func (s *SubnetSlice) CurrentSubnetName() string
func (*SubnetSlice) GetAvailableSubnet ¶
func (s *SubnetSlice) GetAvailableSubnet() (*Subnet, error)
func (*SubnetSlice) GetSubnetByIP ¶
func (s *SubnetSlice) GetSubnetByIP(ip string) (*Subnet, error)
func (*SubnetSlice) Usage ¶
func (s *SubnetSlice) Usage() *Usage