cninetwork

package
v0.0.0-...-599ae54 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CNIBinDir describes the directory where the CNI binaries are stored
	CNIBinDir = "/opt/cni/bin"

	// CNIConfDir describes the directory where the CNI plugin's configuration is stored
	CNIConfDir = "/etc/cni/net.d"

	// NetNSPathFmt gives the path to the a process network namespace, given the pid
	NetNSPathFmt = "/proc/%d/ns/net"

	// CNIDataDir is the directory CNI stores allocated IP for containers
	CNIDataDir = "/var/run/cni"
)

Variables

View Source
var ErrLinkNotFound = errors.New("Link not found")

Functions

func CNIGateway

func CNIGateway() (string, error)

CNIGateway returns the gateway for default subnet

func CreateCNINetwork

func CreateCNINetwork(ctx context.Context, cni gocni.CNI, task containerd.Task, labels map[string]string) (*gocni.CNIResult, error)

CreateCNINetwork creates a CNI network interface and attaches it to the context

func DeleteCNINetwork

func DeleteCNINetwork(ctx context.Context, cni gocni.CNI, client *containerd.Client, name string) error

DeleteCNINetwork deletes a CNI network based on task ID and Pid

func GetIPAddress

func GetIPAddress(container string, PID uint32) (string, error)

GetIPAddress returns the IP address from container based on container name and PID

func InitNetwork

func InitNetwork() (gocni.CNI, error)

InitNetwork writes configlist file and initializes CNI network

func NSPathByPid

func NSPathByPid(pid int) string

func NSPathByPidWithRoot

func NSPathByPidWithRoot(root string, pid int) string

func WithNetNS

func WithNetNS(ns netns.NsHandle, work func() error) error

func WithNetNSByPath

func WithNetNSByPath(path string, work func() error) error
func WithNetNSLink(ns netns.NsHandle, ifName string, work func(link netlink.Link) error) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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