ipam

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ipam contains utility functions to deal with resources of the IPAM API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNetwork

func CreateNetwork(ctx context.Context, cl client.Client, name, namespace, cidr string, needRemapping bool, networkType *consts.NetworkType) error

CreateNetwork creates a Network resource with the given name and CIDR. NeedRemapping indicates whether the Network needs CIDR remapping from IPAM. NetworkType indicates the type of the Network (leave empty to not set the type).

func FirstNIPsFromPrefix

func FirstNIPsFromPrefix(prefix netip.Prefix, num uint32) iter.Seq[netip.Addr]

FirstNIPsFromPrefix returns an iterator with first num IPs from the given prefix.

func GetExternalCIDR

func GetExternalCIDR(ctx context.Context, cl client.Client) (string, error)

GetExternalCIDR retrieves the externalCIDR of the local cluster.

func GetExternalCIDRNetwork

func GetExternalCIDRNetwork(ctx context.Context, cl client.Client) (*ipamv1alpha1.Network, error)

GetExternalCIDRNetwork retrieves the Network resource of type ExternalCIDR.

func GetInternalCIDR

func GetInternalCIDR(ctx context.Context, cl client.Client) (string, error)

GetInternalCIDR retrieves the internalCIDR of the local cluster.

func GetInternalCIDRNetwork

func GetInternalCIDRNetwork(ctx context.Context, cl client.Client) (*ipamv1alpha1.Network, error)

GetInternalCIDRNetwork retrieves the Network resource of type InternalCIDR.

func GetPodCIDR

func GetPodCIDR(ctx context.Context, cl client.Client) (string, error)

GetPodCIDR retrieves the podCIDR of the local cluster.

func GetPodCIDRNetwork

func GetPodCIDRNetwork(ctx context.Context, cl client.Client) (*ipamv1alpha1.Network, error)

GetPodCIDRNetwork retrieves the Network resource of type PodCIDR.

func GetRemappedIP

func GetRemappedIP(ip *ipamv1alpha1.IP) networkingv1beta1.IP

GetRemappedIP returns the remapped IP of the given IP resource.

func GetReservedSubnetNetworks

func GetReservedSubnetNetworks(ctx context.Context, cl client.Client) ([]ipamv1alpha1.Network, error)

GetReservedSubnetNetworks retrieves the Network resources of type Reserved.

func GetReservedSubnets

func GetReservedSubnets(ctx context.Context, cl client.Client) ([]string, error)

GetReservedSubnets retrieves the reserved subnets of the local cluster.

func GetServiceCIDR

func GetServiceCIDR(ctx context.Context, cl client.Client) (string, error)

GetServiceCIDR retrieves the serviceCIDR of the local cluster.

func GetServiceCIDRNetwork

func GetServiceCIDRNetwork(ctx context.Context, cl client.Client) (*ipamv1alpha1.Network, error)

GetServiceCIDRNetwork retrieves the Network resource of type ServiceCIDR.

func GetUnknownSourceIP

func GetUnknownSourceIP(extCIDR string) (string, error)

GetUnknownSourceIP returns the IP address used to map unknown sources.

func IsAPIServerIP

func IsAPIServerIP(ip *ipamv1alpha1.IP) bool

IsAPIServerIP checks if the resource is an IP of type API server.

func IsAPIServerProxyIP

func IsAPIServerProxyIP(ip *ipamv1alpha1.IP) bool

IsAPIServerProxyIP checks if the resource is an IP of type API server proxy.

func IsExternalCIDR

func IsExternalCIDR(nw *ipamv1alpha1.Network) bool

IsExternalCIDR returns whether the given Network is of type ExternalCIDR.

func IsInternalCIDR

func IsInternalCIDR(nw *ipamv1alpha1.Network) bool

IsInternalCIDR returns whether the given Network is of type InternalCIDR.

func IsPodCIDR

func IsPodCIDR(nw *ipamv1alpha1.Network) bool

IsPodCIDR returns whether the given Network is of type PodCIDR.

func IsReservedNetwork

func IsReservedNetwork(nw *ipamv1alpha1.Network) bool

IsReservedNetwork returns whether the given Network is of type Reserved.

func IsServiceCIDR

func IsServiceCIDR(nw *ipamv1alpha1.Network) bool

IsServiceCIDR returns whether the given Network is of type ServiceCIDR.

func NetFirstAndLastIP

func NetFirstAndLastIP(networkCIDR string) (first, last net.IP, err error)

NetFirstAndLastIP takes the beginning address of an entire network in CIDR notation (e.g. 192.168.1.0/24) and returns the first and last IP addresses within the network (e.g. first 192.168.1.0, last 192.168.1.255).

Note that these are the first and last IP addresses, not the first and last *usable* IP addresses (which would be 192.168.1.1 and 192.168.1.254, respectively, for 192.168.1.0/24). Note: this is copied from github.com/google/nftables, copyright Google LLC, licensed under the Apache 2.0 license.

func NetworkNotRemapped

func NetworkNotRemapped(nw *ipamv1alpha1.Network) bool

NetworkNotRemapped returns whether the given Network does not need CIDR remapping.

Types

This section is empty.

Directories

Path Synopsis
Package mapping contains utility functions to deal with the mapping of IPs.
Package mapping contains utility functions to deal with the mapping of IPs.

Jump to

Keyboard shortcuts

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