poolutil

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package poolutil implements utility functions to manage a pool of IP addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressByNamespacedName

func AddressByNamespacedName(addresses []ipamv1.IPAddress, namespace, name string) *ipamv1.IPAddress

AddressByNamespacedName finds a specific ip address by namespace and name in a slice of addresses.

func AddressStrParses

func AddressStrParses(addressStr string) bool

AddressStrParses checks to see that the addresss string is one of a valid single IP address, a hyphonated IP range, or a Prefix.

func AddressToIPSet

func AddressToIPSet(addressStr string) (*netipx.IPSet, error)

AddressToIPSet converts an addresses to an AddressesToIPSet addresses may be specified as individual IPs, CIDR ranges, or hyphenated IP ranges.

func AddressesOutOfRangeIPSet

func AddressesOutOfRangeIPSet(inUseAddresses []ipamv1.IPAddress, poolIPSet *netipx.IPSet) (*netipx.IPSet, error)

AddressesOutOfRangeIPSet returns an IPSet of the inUseAddresses IPs that are not in the poolIPSet.

func AddressesToIPSet

func AddressesToIPSet(addresses []string) (*netipx.IPSet, error)

AddressesToIPSet converts an array of addresses to an AddressesToIPSet addresses may be specified as individual IPs, CIDR ranges, or hyphenated IP ranges.

func FindFreeAddress

func FindFreeAddress(poolIPSet *netipx.IPSet, inUseIPSet *netipx.IPSet) (netip.Addr, error)

FindFreeAddress returns the next free IP Address in a range based on a set of existing addresses.

func IPSetCount

func IPSetCount(ipSet *netipx.IPSet) int

IPSetCount returns the number of IPs contained in the given IPSet. This function returns type int, which is much smaller than the possible size of a range, which could be 2^128 IPs. When an IPSet's count is would be larger than an int, math.MaxInt is returned instead.

func ListAddressesInUse

func ListAddressesInUse(ctx context.Context, c client.Reader, namespace string, poolRef corev1.TypedLocalObjectReference) ([]ipamv1.IPAddress, error)

ListAddressesInUse fetches all IPAddresses belonging to the specified pool. Note: requires `index.ipAddressByCombinedPoolRef` to be set up.

func PoolSpecToIPSet

func PoolSpecToIPSet(poolSpec *v1alpha2.InClusterIPPoolSpec) (*netipx.IPSet, error)

PoolSpecToIPSet converts a pool spec to an IPSet. Reserved addresses will be omitted from the set depending on whether the `spec.AllocateReservedIPAddresses` flag is set.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL