Documentation ¶
Overview ¶
Package eni implements AWS ENI allocation logic
Index ¶
- func StartENIGarbageCollector(ctx context.Context, api EC2API, params GarbageCollectionParams)
- type EC2API
- type GarbageCollectionParams
- type InstancesManager
- func (m *InstancesManager) CreateNode(obj *v2.CiliumNode, n *ipam.Node) ipam.NodeOperations
- func (m *InstancesManager) DeleteInstance(instanceID string)
- func (m *InstancesManager) FindSecurityGroupByTags(vpcID string, required ipamTypes.Tags) []*types.SecurityGroup
- func (m *InstancesManager) FindSubnetByIDs(vpcID, availabilityZone string, subnetIDs []string) (bestSubnet *ipamTypes.Subnet)
- func (m *InstancesManager) FindSubnetByTags(vpcID, availabilityZone string, required ipamTypes.Tags) (bestSubnet *ipamTypes.Subnet)
- func (m *InstancesManager) ForeachInstance(instanceID string, fn ipamTypes.InterfaceIterator)
- func (m *InstancesManager) GetPoolQuota() ipamTypes.PoolQuotaMap
- func (m *InstancesManager) GetSubnet(subnetID string) *ipamTypes.Subnet
- func (m *InstancesManager) GetSubnets(ctx context.Context) ipamTypes.SubnetMap
- func (m *InstancesManager) HasInstance(instanceID string) bool
- func (m *InstancesManager) Resync(ctx context.Context) time.Time
- func (m *InstancesManager) UpdateENI(instanceID string, eni *eniTypes.ENI)
- type InterfaceDB
- type Node
- func (n *Node) AllocateIPs(ctx context.Context, a *ipam.AllocationAction) error
- func (n *Node) CreateInterface(ctx context.Context, allocation *ipam.AllocationAction, ...) (int, string, error)
- func (n *Node) GetMaximumAllocatableIPv4() int
- func (n *Node) GetMinimumAllocatableIPv4() int
- func (n *Node) GetUsedIPWithPrefixes() int
- func (n *Node) IsPrefixDelegated() bool
- func (n *Node) PopulateStatusFields(k8sObj *v2.CiliumNode)
- func (n *Node) PrepareIPAllocation(scopedLog *logrus.Entry) (a *ipam.AllocationAction, err error)
- func (n *Node) PrepareIPRelease(excessIPs int, scopedLog *logrus.Entry) *ipam.ReleaseAction
- func (n *Node) ReleaseIPs(ctx context.Context, r *ipam.ReleaseAction) error
- func (n *Node) ResyncInterfacesAndIPs(ctx context.Context, scopedLog *logrus.Entry) (available ipamTypes.AllocationMap, remainAvailableENIsCount int, err error)
- func (n *Node) UpdatedNode(obj *v2.CiliumNode)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartENIGarbageCollector ¶ added in v1.14.0
func StartENIGarbageCollector(ctx context.Context, api EC2API, params GarbageCollectionParams)
Types ¶
type EC2API ¶ added in v1.14.0
type EC2API interface { GetInstances(ctx context.Context, vpcs ipamTypes.VirtualNetworkMap, subnets ipamTypes.SubnetMap) (*ipamTypes.InstanceMap, error) GetSubnets(ctx context.Context) (ipamTypes.SubnetMap, error) GetVpcs(ctx context.Context) (ipamTypes.VirtualNetworkMap, error) GetSecurityGroups(ctx context.Context) (types.SecurityGroupMap, error) GetDetachedNetworkInterfaces(ctx context.Context, tags ipamTypes.Tags, maxResults int32) ([]string, error) CreateNetworkInterface(ctx context.Context, toAllocate int32, subnetID, desc string, groups []string, allocatePrefixes bool) (string, *eniTypes.ENI, error) AttachNetworkInterface(ctx context.Context, index int32, instanceID, eniID string) (string, error) DeleteNetworkInterface(ctx context.Context, eniID string) error ModifyNetworkInterface(ctx context.Context, eniID, attachmentID string, deleteOnTermination bool) error AssignPrivateIpAddresses(ctx context.Context, eniID string, addresses int32) error UnassignPrivateIpAddresses(ctx context.Context, eniID string, addresses []string) error AssignENIPrefixes(ctx context.Context, eniID string, prefixes int32) error UnassignENIPrefixes(ctx context.Context, eniID string, prefixes []string) error }
EC2API is the API surface used of the EC2 API
type GarbageCollectionParams ¶ added in v1.14.0
type GarbageCollectionParams struct { // RunInterval is both the GC interval and also the minimum amount of time // an ENI has to be available before it is garbage collected RunInterval time.Duration // MaxPerInterval is the maximum number of ENIs which are deleted in a // single interval MaxPerInterval int32 // ENITags is used to only garbage collect ENIs with this set of tags ENITags types.Tags }
type InstancesManager ¶
type InstancesManager struct {
// contains filtered or unexported fields
}
InstancesManager maintains the list of instances. It must be kept up to date by calling resync() regularly.
func NewInstancesManager ¶
func NewInstancesManager(api EC2API) *InstancesManager
NewInstancesManager returns a new instances manager
func (*InstancesManager) CreateNode ¶ added in v1.14.0
func (m *InstancesManager) CreateNode(obj *v2.CiliumNode, n *ipam.Node) ipam.NodeOperations
CreateNode is called on discovery of a new node and returns the ENI node allocation implementation for the new node
func (*InstancesManager) DeleteInstance ¶ added in v1.14.0
func (m *InstancesManager) DeleteInstance(instanceID string)
DeleteInstance delete instance from m.instances
func (*InstancesManager) FindSecurityGroupByTags ¶ added in v1.14.0
func (m *InstancesManager) FindSecurityGroupByTags(vpcID string, required ipamTypes.Tags) []*types.SecurityGroup
FindSecurityGroupByTags returns the security groups matching VPC ID and all required tags
The returned security groups slice is immutable so it can be safely accessed
func (*InstancesManager) FindSubnetByIDs ¶ added in v1.14.0
func (m *InstancesManager) FindSubnetByIDs(vpcID, availabilityZone string, subnetIDs []string) (bestSubnet *ipamTypes.Subnet)
FindSubnetByIDs returns the subnet with the most addresses matching VPC ID, availability zone within a provided list of subnet ids
The returned subnet is immutable so it can be safely accessed
func (*InstancesManager) FindSubnetByTags ¶
func (m *InstancesManager) FindSubnetByTags(vpcID, availabilityZone string, required ipamTypes.Tags) (bestSubnet *ipamTypes.Subnet)
FindSubnetByTags returns the subnet with the most addresses matching VPC ID, availability zone and all required tags
The returned subnet is immutable so it can be safely accessed
func (*InstancesManager) ForeachInstance ¶ added in v1.14.0
func (m *InstancesManager) ForeachInstance(instanceID string, fn ipamTypes.InterfaceIterator)
ForeachInstance will iterate over each instance inside `instances`, and call `fn`. This function is read-locked for the entire execution.
func (*InstancesManager) GetPoolQuota ¶ added in v1.14.0
func (m *InstancesManager) GetPoolQuota() ipamTypes.PoolQuotaMap
GetPoolQuota returns the number of available IPs in all IP pools
func (*InstancesManager) GetSubnet ¶
func (m *InstancesManager) GetSubnet(subnetID string) *ipamTypes.Subnet
GetSubnet returns the subnet by subnet ID
The returned subnet is immutable so it can be safely accessed
func (*InstancesManager) GetSubnets ¶
func (m *InstancesManager) GetSubnets(ctx context.Context) ipamTypes.SubnetMap
GetSubnets returns all the tracked subnets
The returned subnetMap is immutable so it can be safely accessed
func (*InstancesManager) HasInstance ¶ added in v1.14.0
func (m *InstancesManager) HasInstance(instanceID string) bool
HasInstance returns whether the instance is in instances
type InterfaceDB ¶ added in v1.14.0
InterfaceDB contains all the ENIs on a given node. It is used to convert ENI MAC addrs from interface numbers and vice versa, needed for the ENI migration. See https://github.com/go-faster/cilium/issues/14336.
func (*InterfaceDB) GetInterfaceNumberByMAC ¶ added in v1.14.0
func (in *InterfaceDB) GetInterfaceNumberByMAC(mac string) (int, error)
GetInterfaceNumberByMAC implements the linuxrouting.interfaceDB interface. It retrieves the number associated with the ENI device for the given MAC address. The interface number is retrieved from the CiliumNode resource, as this functionality is needed for ENI mode.
func (*InterfaceDB) GetMACByInterfaceNumber ¶ added in v1.14.0
func (in *InterfaceDB) GetMACByInterfaceNumber(ifaceNum int) (string, error)
GetMACByInterfaceNumber retrieves the MAC address from a given ENI's interface number. This implements the linuxrouting.interfaceDB interface.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a Kubernetes node running Cilium with an associated CiliumNode custom resource
func NewNode ¶ added in v1.14.0
func NewNode(node *ipam.Node, k8sObj *v2.CiliumNode, manager *InstancesManager) *Node
NewNode returns a new Node
func (*Node) AllocateIPs ¶ added in v1.14.0
AllocateIPs performs the ENI allocation oepration
func (*Node) CreateInterface ¶ added in v1.14.0
func (n *Node) CreateInterface(ctx context.Context, allocation *ipam.AllocationAction, scopedLog *logrus.Entry) (int, string, error)
CreateInterface creates an additional interface with the instance and attaches it to the instance as specified by the CiliumNode. neededAddresses of secondary IPs are assigned to the interface up to the maximum number of addresses as allowed by the instance.
func (*Node) GetMaximumAllocatableIPv4 ¶ added in v1.14.0
GetMaximumAllocatableIPv4 returns the maximum amount of IPv4 addresses that can be allocated to the instance
func (*Node) GetMinimumAllocatableIPv4 ¶ added in v1.14.0
GetMinimumAllocatableIPv4 returns the minimum amount of IPv4 addresses that must be allocated to the instance.
func (*Node) GetUsedIPWithPrefixes ¶ added in v1.14.0
GetUsedIPWithPrefixes returns the total number of used IPs on the node including the prefixes allocated. A prefix is considered as used if there is at least one allocated IP from that prefix. All IPs from a used prefix are included in the count returned.
func (*Node) IsPrefixDelegated ¶ added in v1.14.0
IsPrefixDelegated indicates whether prefix delegation can be enabled on a node. Currently, mixed usage of secondary IPs and prefixes is not supported. n.mutex read lock must be held before calling this method.
func (*Node) PopulateStatusFields ¶ added in v1.14.0
func (n *Node) PopulateStatusFields(k8sObj *v2.CiliumNode)
PopulateStatusFields fills in the status field of the CiliumNode custom resource with ENI specific information
func (*Node) PrepareIPAllocation ¶ added in v1.14.0
PrepareIPAllocation returns the number of ENI IPs and interfaces that can be allocated/created.
func (*Node) PrepareIPRelease ¶ added in v1.14.0
PrepareIPRelease prepares the release of ENI IPs.
func (*Node) ReleaseIPs ¶ added in v1.14.0
ReleaseIPs performs the ENI IP release operation
func (*Node) ResyncInterfacesAndIPs ¶ added in v1.14.0
func (n *Node) ResyncInterfacesAndIPs(ctx context.Context, scopedLog *logrus.Entry) (available ipamTypes.AllocationMap, remainAvailableENIsCount int, err error)
ResyncInterfacesAndIPs is called to retrieve and ENIs and IPs as known to the EC2 API and return them
func (*Node) UpdatedNode ¶ added in v1.14.0
func (n *Node) UpdatedNode(obj *v2.CiliumNode)
UpdatedNode is called when an update to the CiliumNode is received.