network

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConnectionToHost

func CheckConnectionToHost(ctx context.Context, targetURL url.URL, opts ...ConnectionOption) error

CheckConnectionToHost checks if a connection can be established to the host specified in the URL.

func ContainsIP added in v1.0.10

func ContainsIP(cidr string, ip net.IP) (bool, error)

ContainsIP checks if the given IP is within the specified CIDR block

func ExtractCIDRsFromNodeNetworks added in v1.0.10

func ExtractCIDRsFromNodeNetworks(networks []types.RemoteNodeNetwork) []string

ExtractCIDRsFromNodeNetworks extracts CIDR blocks from remote node networks

func ExtractFlagValue added in v1.0.10

func ExtractFlagValue(args []string, flag string) string

ExtractFlagValue extracts the value of a specific flag from kubelet arguments

func ExtractNodeIPFromFlags added in v1.0.10

func ExtractNodeIPFromFlags(kubeletArgs []string) (net.IP, error)

ExtractNodeIPFromFlags extracts the node IP from kubelet flags

func FindNetworkInterfaceForIP added in v1.0.10

func FindNetworkInterfaceForIP(nodeIP net.IP) (*net.Interface, error)

FindNetworkInterfaceForIP finds the network interface that has the given IP address

func GetNodeIP added in v1.0.10

func GetNodeIP(kubeletArgs []string, nodeName string, network Network) (net.IP, error)

GetNodeIP determines the node's IP address based on kubelet configuration and system information.

func IsIPInCIDRs added in v1.0.10

func IsIPInCIDRs(ip net.IP, cidrs []string) (bool, error)

IsIPInCIDRs checks if the given IP is within any of the specified CIDR blocks

func IsProxyEnabled added in v1.0.10

func IsProxyEnabled() bool

func ValidateClusterRemoteNetworkConfig added in v1.0.10

func ValidateClusterRemoteNetworkConfig(cluster *types.Cluster) error

ValidateClusterRemoteNetworkConfig validates that the cluster has proper remote network configuration

func ValidateIPInRemoteNodeNetwork added in v1.0.10

func ValidateIPInRemoteNodeNetwork(ipAddr net.IP, remoteNodeNetwork []types.RemoteNodeNetwork) error

ValidateIPInRemoteNodeNetwork validates that the given IP is within the remote node networks

func ValidateMTU added in v1.0.10

func ValidateMTU(mtu int) error

ValidateMTU validates that the MTU value is within acceptable ranges MTU should be <= 1500 (standard Ethernet) or between 8000-9001 (jumbo frames)

func ValidateNetworkInterfaceMTUForIP added in v1.0.10

func ValidateNetworkInterfaceMTUForIP(nodeIP net.IP) error

ValidateNetworkInterfaceMTUForIP validates MTU for the network interface associated with the given IP

func ValidateNodeIP added in v1.0.10

func ValidateNodeIP(nodeIP net.IP, network Network) error

ValidateNodeIP validates that the given node IP belongs to the current host.

ValidateNodeIP adapts the unexported 'validateNodeIP' function from kubelet. Source: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet_node_status.go#L796

func WithCluster added in v1.0.10

func WithCluster(cluster *types.Cluster) func(*NetworkInterfaceValidator)

func WithMTUValidation added in v1.0.10

func WithMTUValidation(validate bool) func(*NetworkInterfaceValidator)

func WithNetwork added in v1.0.10

func WithNetwork(network Network) func(*NetworkInterfaceValidator)

Types

type ConnectionOption added in v1.0.7

type ConnectionOption func(*ConnectionOptions)

func WithProxyFunc added in v1.0.7

func WithProxyFunc(f func(*url.URL) (*url.URL, error)) ConnectionOption

this is overridable mainly for testing purposes to avoid using environment variables to manipulate the proxy environment and because the default ProxyFunc always skips the proxy for localhost/loopback addresses, it does not require that they be listed in the NO_PROXY environment variable. This makes testing difficult since we would need to manipulate the dns resolution on the test machine (ex: modify /etc/hosts).

type ConnectionOptions added in v1.0.7

type ConnectionOptions struct {
	// ProxyFunc determines which proxy to use for a given request.
	// If nil, uses httpproxy.FromEnvironment().ProxyFunc()
	ProxyFunc func(*url.URL) (*url.URL, error)
}

type DefaultKubeletNetwork added in v1.0.10

type DefaultKubeletNetwork struct{}

DefaultKubeletNetwork provides the network util functions used by kubelet.

func (DefaultKubeletNetwork) InterfaceAddrs added in v1.0.10

func (u DefaultKubeletNetwork) InterfaceAddrs() ([]net.Addr, error)

func (DefaultKubeletNetwork) LookupIP added in v1.0.10

func (u DefaultKubeletNetwork) LookupIP(host string) ([]net.IP, error)

func (DefaultKubeletNetwork) ResolveBindAddress added in v1.0.10

func (u DefaultKubeletNetwork) ResolveBindAddress(bindAddress net.IP) (net.IP, error)

type Network added in v1.0.10

type Network interface {
	LookupIP(host string) ([]net.IP, error)
	ResolveBindAddress(bindAddress net.IP) (net.IP, error)
	InterfaceAddrs() ([]net.Addr, error)
}

Network interfaces with the host's network stack.

func NewDefaultNetwork added in v1.0.10

func NewDefaultNetwork() Network

NewDefaultNetwork creates a new instance of DefaultKubeletNetwork

type NetworkInterfaceValidator added in v1.0.10

type NetworkInterfaceValidator struct {
	// contains filtered or unexported fields
}

func NewNetworkInterfaceValidator added in v1.0.10

func NewNetworkInterfaceValidator(opts ...func(*NetworkInterfaceValidator)) NetworkInterfaceValidator

func (NetworkInterfaceValidator) Run added in v1.0.10

type ProxyValidator added in v1.0.10

type ProxyValidator struct{}

ProxyValidator validates proxy configuration

func NewProxyValidator added in v1.0.10

func NewProxyValidator() ProxyValidator

NewProxyValidator creates a new ProxyValidator

func (ProxyValidator) Run added in v1.0.10

func (v ProxyValidator) Run(ctx context.Context, informer validation.Informer, node *api.NodeConfig) error

Run validates proxy configuration

func (ProxyValidator) Validate added in v1.0.10

func (v ProxyValidator) Validate(node *api.NodeConfig) error

Jump to

Keyboard shortcuts

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