hostport

package
v1.29.3 Latest Latest
Warning

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

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

README

CRI-O logo

Host Port Manager

The Host Port Managers maps ports from the Host to the specified Container Port. It can also specify the Host IP that should be mapped to the container IP. For security reasons, it also opens a socket in the host to avoid any process in the system that could interfere with the traffic that is being port mapped.

hostport

This code is copied from the kubernetes/kubernetes repo Since Kubernetes started the deprecation of that part of the code in #94624, it is missing some fixes and the features required to operate correctly in dual stack environments.

The kubernetes/kubernetes repo has a fix where the host port manager always opens a socket in all addresses, instead of leveraging the HostIP field: #94382

The current implementation only maps ports for the first IP of each IP family obtained from the CNI results.

Documentation

Index

Constants

View Source
const (
	IPv4 ipFamily = "4"
	IPv6 ipFamily = "6"
)

Constants for valid IPFamily:

Variables

This section is empty.

Functions

This section is empty.

Types

type HostPortManager

type HostPortManager interface {
	// Add implements port mappings.
	// id should be a unique identifier for a pod, e.g. podSandboxID.
	// podPortMapping is the associated port mapping information for the pod.
	// natInterfaceName is the interface that localhost uses to talk to the given pod, if known.
	Add(id string, podPortMapping *PodPortMapping, natInterfaceName string) error
	// Remove cleans up matching port mappings
	// Remove must be able to clean up port mappings without pod IP
	Remove(id string, podPortMapping *PodPortMapping) error
}

HostPortManager is an interface for adding and removing hostport for a given pod sandbox. nolint:golint // no reason to change the type name now "type name will be used as hostport.HostPortManager by other packages"

func NewHostportManager

func NewHostportManager(iptables utiliptables.Interface) HostPortManager

NewHostportManager creates a new HostPortManager

func NewMetaHostportManager

func NewMetaHostportManager() HostPortManager

NewMetaHostportManager creates a new HostPortManager

func NewNoopHostportManager added in v1.28.0

func NewNoopHostportManager() HostPortManager

NewNoopHostportManager creates a new HostPortManager

type PodPortMapping

type PodPortMapping struct {
	Namespace    string
	Name         string
	PortMappings []*PortMapping
	HostNetwork  bool
	IP           net.IP
}

PodPortMapping represents a pod's network state and associated container port mappings

type PortMapping

type PortMapping struct {
	HostPort      int32
	ContainerPort int32
	Protocol      v1.Protocol
	HostIP        string
}

PortMapping represents a network port in a container

Jump to

Keyboard shortcuts

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