Documentation
¶
Index ¶
- Constants
- func Split[T any](arr []T, index int) ([]T, []T)
- type AllocRequest
- type AllocResp
- type AllocatingRequests
- type ByPriority
- type CRDV2
- func (r *CRDV2) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
- func (r *CRDV2) Dispose(n int) int
- func (r *CRDV2) Priority() int
- func (r *CRDV2) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
- func (r *CRDV2) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
- type Condition
- type ConditionType
- type ENIID
- type ENILocalIPAM
- func (e *ENILocalIPAM) AllocateIPv4(podID string) (netip.Addr, error)
- func (e *ENILocalIPAM) AllocateIPv6(podID string) (netip.Addr, error)
- func (e *ENILocalIPAM) AllocationCount() int
- func (e *ENILocalIPAM) HasAllocations() bool
- func (e *ENILocalIPAM) IsERDMA() bool
- func (e *ENILocalIPAM) IsEmpty() bool
- func (e *ENILocalIPAM) PoolStats() (int, int, int, int)
- func (e *ENILocalIPAM) ReleaseIPv4(podID string)
- func (e *ENILocalIPAM) ReleaseIPv6(podID string)
- func (e *ENILocalIPAM) RestorePod(podID string, ipv4, ipv6 string, eniID string)
- func (e *ENILocalIPAM) StatusSnapshot() (eniID, mac string, ipv4 []PrefixStatus, ipv6 []PrefixStatus)
- func (e *ENILocalIPAM) UpdatePrefixes(prefixes []networkv1beta1.IPPrefix, isIPv6 bool)
- type IP
- type Local
- func (l *Local) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
- func (l *Local) Dispose(n int) int
- func (l *Local) Priority() int
- func (l *Local) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
- func (l *Local) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
- func (l *Local) Status() Status
- func (l *Local) Usage() (int, int, error)
- type LocalDelegate
- func (l *LocalDelegate) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
- func (l *LocalDelegate) Dispose(n int) int
- func (l *LocalDelegate) Priority() int
- func (l *LocalDelegate) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
- func (l *LocalDelegate) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
- func (l *LocalDelegate) Statuses() []Status
- type LocalIPRequest
- type LocalIPResource
- type Manager
- func (m *Manager) Allocate(ctx context.Context, cni *daemon.CNI, req *AllocRequest) (NetworkResources, error)
- func (m *Manager) Release(ctx context.Context, cni *daemon.CNI, req *ReleaseRequest) error
- func (m *Manager) Run(ctx context.Context, wg *sync.WaitGroup, podResources []daemon.PodResources) error
- func (m *Manager) Status() []Status
- type MultiReportStatus
- type NetworkInterface
- type NetworkResource
- type NetworkResources
- type NodeCondition
- type NodeConditionHandler
- type Notifier
- type PrefixAllocation
- type PrefixInfo
- type PrefixStatus
- type ReleaseRequest
- type Remote
- func (r *Remote) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
- func (r *Remote) Dispose(n int) int
- func (r *Remote) Priority() int
- func (r *Remote) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
- func (r *Remote) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
- type RemoteIPRequest
- type RemoteIPResource
- type RemoteV2
- func (r *RemoteV2) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
- func (r *RemoteV2) Dispose(n int) int
- func (r *RemoteV2) Priority() int
- func (r *RemoteV2) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
- func (r *RemoteV2) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
- type ReportStatus
- type ResourceRequest
- type ResourceType
- type Set
- func (s Set) Add(ip *IP)
- func (s Set) Allocatable() []*IP
- func (s Set) ByPodID(podID string) *IP
- func (s Set) Delete(ip ...netip.Addr)
- func (s Set) Deleting() []netip.Addr
- func (s Set) Idles() []*IP
- func (s Set) InUse() []*IP
- func (s Set) PeekAvailable(podID string) *IP
- func (s Set) PutDeleting(ip ...netip.Addr)
- func (s Set) PutValid(ip ...netip.Addr)
- func (s Set) Release(podID string, ip netip.Addr)
- type SharedCRDManager
- type Status
- type Trace
- type Trunk
- func (r *Trunk) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
- func (r *Trunk) Dispose(n int) int
- func (r *Trunk) Priority() int
- func (r *Trunk) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
- func (r *Trunk) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
- func (r *Trunk) Status() Status
- func (r *Trunk) Usage() (int, int, error)
- type Usage
Constants ¶
const ( ResourceTypeLocalIP = 1 << iota ResourceTypeVeth ResourceTypeRemoteIP ResourceTypeRDMA )
const IPv6PrefixMaxAddresses uint = 65536
IPv6PrefixMaxAddresses caps the managed address range for large IPv6 prefixes (e.g. /80 with 2^48 host bits). Addresses are formed as:
[prefix bits][zeros][16-bit offset]
so only the lowest 16 bits are used, giving 65536 usable addresses per prefix.
const (
LocalIPTypeERDMA = "ERDMA"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AllocRequest ¶
type AllocRequest struct {
ResourceRequests []ResourceRequest
}
AllocRequest represent a bunch of resource must be met.
type AllocResp ¶
type AllocResp struct {
Err error
NetworkConfigs NetworkResources
}
type AllocatingRequests ¶ added in v1.8.18
type AllocatingRequests []*LocalIPRequest
func (*AllocatingRequests) Len ¶ added in v1.8.18
func (a *AllocatingRequests) Len() int
Len return the valid slice size
type ByPriority ¶
type ByPriority []NetworkInterface
func (ByPriority) Len ¶
func (n ByPriority) Len() int
func (ByPriority) Less ¶
func (n ByPriority) Less(i, j int) bool
func (ByPriority) Swap ¶
func (n ByPriority) Swap(i, j int)
type CRDV2 ¶ added in v1.9.6
type CRDV2 struct {
// contains filtered or unexported fields
}
func NewCRDV2 ¶ added in v1.9.6
func NewCRDV2(sharedMgr *SharedCRDManager, nodeName string) *CRDV2
type ConditionType ¶
type ConditionType int
const ( Full ConditionType = iota ResourceTypeMismatch NetworkInterfaceMismatch InsufficientVSwitchIP )
func (ConditionType) String ¶
func (i ConditionType) String() string
type ENILocalIPAM ¶ added in v1.17.1
type ENILocalIPAM struct {
// contains filtered or unexported fields
}
func NewENILocalIPAMFromPrefix ¶ added in v1.17.1
func NewENILocalIPAMFromPrefix(eniID, mac string, eni *networkv1beta1.Nic, enableERDMA bool) *ENILocalIPAM
NewENILocalIPAMFromPrefix builds a Prefix-mode IPAM from Node CR's IPv4Prefix/IPv6Prefix.
func (*ENILocalIPAM) AllocateIPv4 ¶ added in v1.17.1
func (e *ENILocalIPAM) AllocateIPv4(podID string) (netip.Addr, error)
func (*ENILocalIPAM) AllocateIPv6 ¶ added in v1.17.1
func (e *ENILocalIPAM) AllocateIPv6(podID string) (netip.Addr, error)
func (*ENILocalIPAM) AllocationCount ¶ added in v1.17.1
func (e *ENILocalIPAM) AllocationCount() int
AllocationCount returns the total number of pod allocations (IPv4 + IPv6) in this IPAM.
func (*ENILocalIPAM) HasAllocations ¶ added in v1.17.1
func (e *ENILocalIPAM) HasAllocations() bool
HasAllocations returns true if any pod is currently using an IP from this IPAM.
func (*ENILocalIPAM) IsERDMA ¶ added in v1.17.1
func (e *ENILocalIPAM) IsERDMA() bool
IsERDMA returns true when both the node has ERDMA enabled and the NIC is in high-performance traffic mode.
func (*ENILocalIPAM) IsEmpty ¶ added in v1.17.1
func (e *ENILocalIPAM) IsEmpty() bool
IsEmpty returns true when the IPAM has no prefixes left (all drained and cleaned up).
func (*ENILocalIPAM) PoolStats ¶ added in v1.17.1
func (e *ENILocalIPAM) PoolStats() (int, int, int, int)
PoolStats returns (totalIPv4, idleIPv4, totalIPv6, idleIPv6).
func (*ENILocalIPAM) ReleaseIPv4 ¶ added in v1.17.1
func (e *ENILocalIPAM) ReleaseIPv4(podID string)
ReleaseIPv4 releases an IPv4 address.
func (*ENILocalIPAM) ReleaseIPv6 ¶ added in v1.17.1
func (e *ENILocalIPAM) ReleaseIPv6(podID string)
ReleaseIPv6 releases an IPv6 address.
func (*ENILocalIPAM) RestorePod ¶ added in v1.17.1
func (e *ENILocalIPAM) RestorePod(podID string, ipv4, ipv6 string, eniID string)
RestorePod restores the IP allocation state for a Pod.
func (*ENILocalIPAM) StatusSnapshot ¶ added in v1.17.1
func (e *ENILocalIPAM) StatusSnapshot() (eniID, mac string, ipv4 []PrefixStatus, ipv6 []PrefixStatus)
StatusSnapshot exports a point-in-time snapshot of ENI identity and per-prefix allocations.
func (*ENILocalIPAM) UpdatePrefixes ¶ added in v1.17.1
func (e *ENILocalIPAM) UpdatePrefixes(prefixes []networkv1beta1.IPPrefix, isIPv6 bool)
UpdatePrefixes syncs the local prefix state with the Node CR's prefix list. Prefixes removed from the CR (or marked Deleting) are set to Deleting locally, which blocks new allocations via sortedValidPrefixes. Once all Pods drain from a Deleting prefix, it is cleaned up on the next call.
type IP ¶
type IP struct {
// contains filtered or unexported fields
}
func (*IP) Allocatable ¶
func (*IP) SetInvalid ¶
func (ip *IP) SetInvalid()
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
func (*Local) Release ¶
func (l *Local) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
Release take the cni Del request and release resource to pool
type LocalDelegate ¶ added in v1.17.1
type LocalDelegate struct {
// contains filtered or unexported fields
}
func NewLocalDelegate ¶ added in v1.17.1
func NewLocalDelegate(sharedMgr *SharedCRDManager, nodeName string, enableIPv4, enableIPv6 bool) *LocalDelegate
func (*LocalDelegate) Allocate ¶ added in v1.17.1
func (l *LocalDelegate) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
Allocate implements NetworkInterface. Returns nil channel when inactive so the Manager falls through to the next NetworkInterface (CRDV2).
func (*LocalDelegate) Dispose ¶ added in v1.17.1
func (l *LocalDelegate) Dispose(n int) int
func (*LocalDelegate) Priority ¶ added in v1.17.1
func (l *LocalDelegate) Priority() int
func (*LocalDelegate) Release ¶ added in v1.17.1
func (l *LocalDelegate) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
Release implements NetworkInterface. Returns (false, nil) when inactive so the Manager falls through to the next NetworkInterface (CRDV2).
func (*LocalDelegate) Run ¶ added in v1.17.1
func (l *LocalDelegate) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
Run implements NetworkInterface. It waits for the shared cache to sync, registers Node CR informer handlers, and performs synchronous initialization so the delegate is ready for allocation before Run returns.
func (*LocalDelegate) Statuses ¶ added in v1.17.1
func (l *LocalDelegate) Statuses() []Status
type LocalIPRequest ¶
type LocalIPRequest struct {
NetworkInterfaceID string
LocalIPType string
IPv4 netip.Addr
IPv6 netip.Addr
NoCache bool // do not use cached ip
// contains filtered or unexported fields
}
func NewLocalIPRequest ¶ added in v1.8.18
func NewLocalIPRequest() *LocalIPRequest
func (*LocalIPRequest) ResourceType ¶
func (l *LocalIPRequest) ResourceType() ResourceType
type LocalIPResource ¶
func (*LocalIPResource) ResourceType ¶
func (l *LocalIPResource) ResourceType() ResourceType
func (*LocalIPResource) ToRPC ¶
func (l *LocalIPResource) ToRPC() []*rpc.NetConf
func (*LocalIPResource) ToStore ¶
func (l *LocalIPResource) ToStore() []daemon.ResourceItem
type Manager ¶
func NewManager ¶
func NewManager(pool *daemon.PoolConfig, syncPeriod time.Duration, networkInterfaces []NetworkInterface, selectionPolicy daemon.EniSelectionPolicy, k8s k8s.Kubernetes) *Manager
func (*Manager) Allocate ¶
func (m *Manager) Allocate(ctx context.Context, cni *daemon.CNI, req *AllocRequest) (NetworkResources, error)
Allocate find the resource manager and send the request to it. Caller should roll back the allocated resource if any error happen.
type MultiReportStatus ¶ added in v1.17.1
type MultiReportStatus interface {
Statuses() []Status
}
type NetworkInterface ¶
type NetworkInterface interface {
Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
Priority() int
Dispose(n int) int
Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
}
type NetworkResource ¶
type NetworkResource interface {
ResourceType() ResourceType
ToRPC() []*rpc.NetConf
ToStore() []daemon.ResourceItem
}
type NetworkResources ¶
type NetworkResources []NetworkResource
type NodeCondition ¶
type NodeCondition struct {
// contains filtered or unexported fields
}
func (*NodeCondition) Run ¶
func (n *NodeCondition) Run()
func (*NodeCondition) SetIPExhaustive ¶
func (n *NodeCondition) SetIPExhaustive()
func (*NodeCondition) UnsetIPExhaustive ¶
func (n *NodeCondition) UnsetIPExhaustive()
type NodeConditionHandler ¶
type NodeConditionHandler func(status corev1.ConditionStatus, reason, message string) error
type Notifier ¶ added in v1.15.1
type Notifier struct {
// contains filtered or unexported fields
}
Notifier provides a simple message subscription-based notification mechanism
func (*Notifier) Close ¶ added in v1.15.1
func (n *Notifier) Close()
Close closes the notifier and cleans up all subscribers
func (*Notifier) GetSubscriberCount ¶ added in v1.15.1
GetSubscriberCount gets the current number of subscribers (for debugging and monitoring)
func (*Notifier) Notify ¶ added in v1.15.1
func (n *Notifier) Notify()
Notify sends notifications to all subscribers
func (*Notifier) Subscribe ¶ added in v1.15.1
func (n *Notifier) Subscribe() <-chan struct{}
Subscribe registers a subscriber and returns a subscription channel
func (*Notifier) Unsubscribe ¶ added in v1.15.1
func (n *Notifier) Unsubscribe(ch <-chan struct{})
Unsubscribe removes a subscriber by channel reference
type PrefixAllocation ¶ added in v1.17.1
type PrefixInfo ¶ added in v1.17.1
type PrefixInfo struct {
Prefix string
// contains filtered or unexported fields
}
type PrefixStatus ¶ added in v1.17.1
type ReleaseRequest ¶
type ReleaseRequest struct {
NetworkResources []NetworkResource
}
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
type RemoteIPRequest ¶
type RemoteIPRequest struct{}
func (*RemoteIPRequest) ResourceType ¶
func (l *RemoteIPRequest) ResourceType() ResourceType
type RemoteIPResource ¶
type RemoteIPResource struct {
// contains filtered or unexported fields
}
func (*RemoteIPResource) ResourceType ¶
func (l *RemoteIPResource) ResourceType() ResourceType
func (*RemoteIPResource) ToRPC ¶
func (l *RemoteIPResource) ToRPC() []*rpc.NetConf
func (*RemoteIPResource) ToStore ¶
func (l *RemoteIPResource) ToStore() []daemon.ResourceItem
type RemoteV2 ¶ added in v1.17.1
type RemoteV2 struct {
// contains filtered or unexported fields
}
func NewRemoteV2 ¶ added in v1.17.1
func NewRemoteV2(sharedMgr *SharedCRDManager, nodeName string) *RemoteV2
type ReportStatus ¶
type ReportStatus interface {
Status() Status
}
type ResourceRequest ¶
type ResourceRequest interface {
ResourceType() ResourceType
}
type ResourceType ¶
type ResourceType int
type SharedCRDManager ¶ added in v1.17.1
type SharedCRDManager struct {
// contains filtered or unexported fields
}
SharedCRDManager holds the controller-runtime manager shared by peer controllers (CRDV2 and LocalDelegate). It owns the manager lifecycle and cache sync signal.
func NewSharedCRDManager ¶ added in v1.17.1
func NewSharedCRDManager(restConfig *rest.Config, nodeName, namespace string) (*SharedCRDManager, error)
NewSharedCRDManager creates the shared controller-runtime manager with filtered caches for this node and registers the nodeReconcile controller.
func (*SharedCRDManager) CacheSynced ¶ added in v1.17.1
func (s *SharedCRDManager) CacheSynced() <-chan struct{}
func (*SharedCRDManager) Client ¶ added in v1.17.1
func (s *SharedCRDManager) Client() client.Client
func (*SharedCRDManager) GetCache ¶ added in v1.17.1
func (s *SharedCRDManager) GetCache() cache.Cache
func (*SharedCRDManager) Scheme ¶ added in v1.17.1
func (s *SharedCRDManager) Scheme() *runtime.Scheme
type Status ¶
type Status struct {
NetworkInterfaceID string
MAC string
Type string
AllocInhibitExpireAt string
Usage [][]string
Status string
IPv4Prefixes []PrefixStatus
IPv6Prefixes []PrefixStatus
}
type Trace ¶
type Trace struct {
Condition ConditionType
Reason string
}