Documentation ¶
Index ¶
- Constants
- Variables
- type IP
- type IPFamilyMode
- type IPSet
- type IPSlice
- type Network
- func (n *Network) AddSubnet(subnet *Subnet, ips IPSet) error
- func (n *Network) DualStackUsage() ([3]*Usage, map[string]*Usage, error)
- func (n *Network) GetIPv4Subnet(subnetName string) (sn *Subnet, err error)
- func (n *Network) GetIPv6Subnet(subnetName string) (sn *Subnet, err error)
- func (n *Network) GetPairedDualStackSubnets(v4Name, v6Name string) (v4Subnet *Subnet, v6Subnet *Subnet, err error)
- func (n *Network) GetSubnet(subnetName string) (*Subnet, error)
- func (n *Network) GetSubnetByIP(subnetName, ip string) (*Subnet, error)
- func (n *Network) Usage() (*Usage, map[string]*Usage, error)
- type NetworkSet
- func (n NetworkSet) GetNetwork(name string) (*Network, error)
- func (n NetworkSet) GetNetworksByType(networkType NetworkType) (names []string)
- func (n NetworkSet) MatchNetworkType(networkName string, networkType NetworkType) bool
- func (n NetworkSet) RefreshNetwork(name string, network *Network)
- func (n NetworkSet) RemoveNetwork(name string)
- type NetworkType
- 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) 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) Sync(parentNetID *uint32, ipSet IPSet) error
- func (s *Subnet) Usage() *Usage
- func (s *Subnet) UsingIPCount() int
- func (s *Subnet) Validate() error
- type SubnetSlice
- func (s *SubnetSlice) AddSubnet(subnet *Subnet, parentNetID *uint32, ips IPSet, isDefault bool) error
- func (s *SubnetSlice) CurrentSubnet() string
- func (s *SubnetSlice) DualStackUsage() ([3]*Usage, map[string]*Usage, error)
- func (s *SubnetSlice) GetAvailableIPv4Subnet() (*Subnet, error)
- func (s *SubnetSlice) GetAvailableIPv6Subnet() (*Subnet, error)
- func (s *SubnetSlice) GetAvailablePairedDualStackSubnets() (v4Subnet *Subnet, v6Subnet *Subnet, err error)
- 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() (string, map[string]*Usage, error)
- type Usage
Constants ¶
View Source
const ( IPv4Only = IPFamilyMode("IPv4Only") IPv6Only = IPFamilyMode("IPv6Only") DualStack = IPFamilyMode("DualStack") )
View Source
const ( Underlay = NetworkType("Underlay") Overlay = NetworkType("Overlay") )
View Source
const ( IPStatusUsing = "Using" IPStatusReserved = "Reserved" )
Variables ¶
View Source
var ( ErrNoAvailableSubnet = errors.New("no available subnet") ErrNotFoundSubnet = errors.New("subnet not found") ErrNotFoundAssignedIP = errors.New("assigned ip not found") ErrNotAvailableAssignedIP = errors.New("assigned ip is not available") )
View Source
var (
ErrNotFoundNetwork = errors.New("network not found")
)
Functions ¶
This section is empty.
Types ¶
type IP ¶
type IPFamilyMode ¶
type IPFamilyMode string
func ParseIPFamilyFromString ¶
func ParseIPFamilyFromString(in string) IPFamilyMode
type IPSlice ¶
func NewIPSlice ¶
func NewIPSlice() *IPSlice
type Network ¶
type Network struct { // Spec fields Name string NetID *uint32 LastAllocatedSubnet string Type NetworkType Subnets *SubnetSlice }
func NewNetwork ¶
func NewNetwork(name string, netID *uint32, lastAllocatedSubnet string, networkType NetworkType) *Network
func (*Network) DualStackUsage ¶
func (*Network) GetIPv4Subnet ¶
func (*Network) GetIPv6Subnet ¶
func (*Network) GetPairedDualStackSubnets ¶
func (*Network) GetSubnetByIP ¶
type NetworkSet ¶
func NewNetworkSet ¶
func NewNetworkSet() NetworkSet
func (NetworkSet) GetNetwork ¶
func (n NetworkSet) GetNetwork(name string) (*Network, error)
func (NetworkSet) GetNetworksByType ¶
func (n NetworkSet) GetNetworksByType(networkType NetworkType) (names []string)
func (NetworkSet) MatchNetworkType ¶
func (n NetworkSet) MatchNetworkType(networkName string, networkType NetworkType) bool
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
TODO: remove this defaulting logic if overlay become the general option for more users
func ParseNetworkTypeFromString ¶
func ParseNetworkTypeFromString(in string) NetworkType
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 SubnetSlice ¶
type SubnetSlice struct { Subnets []*Subnet SubnetIndexMap map[string]int SubnetIndex int SubnetCount int }
func NewSubnetSlice ¶
func NewSubnetSlice() *SubnetSlice
func (*SubnetSlice) CurrentSubnet ¶
func (s *SubnetSlice) CurrentSubnet() string
func (*SubnetSlice) DualStackUsage ¶
func (s *SubnetSlice) DualStackUsage() ([3]*Usage, map[string]*Usage, error)
func (*SubnetSlice) GetAvailableIPv4Subnet ¶
func (s *SubnetSlice) GetAvailableIPv4Subnet() (*Subnet, error)
func (*SubnetSlice) GetAvailableIPv6Subnet ¶
func (s *SubnetSlice) GetAvailableIPv6Subnet() (*Subnet, error)
func (*SubnetSlice) GetAvailablePairedDualStackSubnets ¶
func (s *SubnetSlice) GetAvailablePairedDualStackSubnets() (v4Subnet *Subnet, v6Subnet *Subnet, err error)
func (*SubnetSlice) GetAvailableSubnet ¶
func (s *SubnetSlice) GetAvailableSubnet() (*Subnet, error)
func (*SubnetSlice) GetSubnetByIP ¶
func (s *SubnetSlice) GetSubnetByIP(ip string) (*Subnet, error)
Click to show internal directories.
Click to hide internal directories.