networking

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCNIPortMapping

func ParseCNIPortMapping(pm *tasksv1.PortMapping) gocni.PortMapping

func ParseCNIPortMappings

func ParseCNIPortMappings(pm ...*tasksv1.PortMapping) []gocni.PortMapping

func ParsePortMapping

func ParsePortMapping(pm gocni.PortMapping) *tasksv1.PortMapping

func ParsePortMappings

func ParsePortMappings(pm ...gocni.PortMapping) []*tasksv1.PortMapping

Types

type CNIManager

type CNIManager struct {

	// CNIBinDir describes the directory where the CNI binaries are stored
	CNIBinDir string

	// CNIConfDir describes the directory where the CNI plugin's configuration is stored
	CNIConfDir string

	// NetNSPathFmt gives the path to the a process network namespace, given the pid
	NetNSPathFmt string

	// CNIDataDir is the directory CNI stores allocated IP for containers
	CNIDataDir string

	// defaultCNIConfFilename is the vanity filename of default CNI configuration file
	DefaultCNIConfFilename string

	// defaultNetworkName names the "docker-bridge"-like CNI plugin-chain installed when no other CNI configuration is present.
	// This value appears in iptables comments created by CNI.
	DefaultNetworkName string

	// defaultBridgeName is the default bridge device name used in the defaultCNIConf
	DefaultBridgeName string

	// defaultSubnet is the default subnet used in the defaultCNIConf -- this value is set to not collide with common container networking subnets:
	DefaultSubnet string

	// defaultSubnetGw is the gateway used for the subnet as defined in defaultSubnet
	DefaultSubnetGw string

	// defaultIfPrefix is the interface name to be created in the container
	DefaultIfPrefix string

	// DefaultCNIConf is the CNI configuration file used by pluginsto setup networking
	DefaultCNIConf string
	// contains filtered or unexported fields
}

func (*CNIManager) Attach

func (c *CNIManager) Attach(ctx context.Context, containerID string, containerPID uint32, opts ...gocni.NamespaceOpts) error

Attach implements Manager.

func (*CNIManager) Check

func (c *CNIManager) Check(ctx context.Context, containerID string, containerPID uint32, opts ...gocni.NamespaceOpts) error

Check implements Manager.

func (*CNIManager) Detach

func (c *CNIManager) Detach(ctx context.Context, containerID string, containerPID uint32, opts ...gocni.NamespaceOpts) error

Detach implements Manager.

func (*CNIManager) GetIPAddress

func (c *CNIManager) GetIPAddress(id string) (net.IP, error)

type CNIManagerOpts

type CNIManagerOpts func(*CNIManager) error

func WithCNIBinDir

func WithCNIBinDir(s string) CNIManagerOpts

func WithCNIConfDir

func WithCNIConfDir(s string) CNIManagerOpts

func WithCNIDataDir

func WithCNIDataDir(s string) CNIManagerOpts

func WithCNIOpt

func WithCNIOpt(opt ...gocni.Opt) CNIManagerOpts

func WithDefaultBridgeName

func WithDefaultBridgeName(s string) CNIManagerOpts

func WithDefaultCNIConf

func WithDefaultCNIConf(s string) CNIManagerOpts

func WithDefaultCNIConfFilename

func WithDefaultCNIConfFilename(s string) CNIManagerOpts

func WithDefaultIfPrefix

func WithDefaultIfPrefix(s string) CNIManagerOpts

func WithDefaultNetworkName

func WithDefaultNetworkName(s string) CNIManagerOpts

func WithDefaultSubnet

func WithDefaultSubnet(s string) CNIManagerOpts

func WithNamespaceOpts

func WithNamespaceOpts(opts ...gocni.NamespaceOpts) CNIManagerOpts

func WithNetNSPathFmt

func WithNetNSPathFmt(s string) CNIManagerOpts

type Manager

type Manager interface {
	Attach(ctx context.Context, containerID string, containerPID uint32, opts ...gocni.NamespaceOpts) error
	Detach(ctx context.Context, containerID string, containerPID uint32, opts ...gocni.NamespaceOpts) error
	Check(ctx context.Context, containerID string, containerPID uint32, opts ...gocni.NamespaceOpts) error
}

func NewCNIManager

func NewCNIManager(opts ...CNIManagerOpts) (Manager, error)

type PortMapping

type PortMapping struct {
	Source      uint32
	Destination uint32
}

func ParsePorts

func ParsePorts(p string) (*PortMapping, error)

func (*PortMapping) String

func (p *PortMapping) String() string

Jump to

Keyboard shortcuts

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